/*
 * 
 * 根据 MIT 许可证条款分发。
 *
 * 作者：Amor
 */

/*! BControlLook：模仿 Ant Design 的桃花色彩方案 */

#include "AntRedControlLook.h"

#include <Alignment.h>
#include <Bitmap.h>
#include <Button.h>
#include <Control.h>
#include <GradientLinear.h>
#include <LayoutUtils.h>
#include <Region.h>
#include <Shape.h>
#include <String.h>
#include <TabView.h>
#include <View.h>
#include <Window.h>
#include <WindowPrivate.h>

#include <algorithm>
#include <cmath>

// #define DEBUG_CONTROL_LOOK
#ifdef DEBUG_CONTROL_LOOK
#define STRACE(x) printf x
#else
#define STRACE(x) ;
#endif

// Ant Design color palette with peach blossom theme
// Primary colors
static const rgb_color kAntPrimaryColor = {255, 105, 180, 255};  // 桃花缘主色
static const rgb_color kAntPrimaryLight = {255, 150, 200, 255};  // 浅色变体
static const rgb_color kAntPrimaryDark = {220, 70, 150, 255};    // 深色变体

// Neutral colors
static const rgb_color kAntNeutral1 = {255, 255, 255, 255};  // 白色
static const rgb_color kAntNeutral2 = {250, 250, 250, 255};  // 背景色
static const rgb_color kAntNeutral3 = {245, 245, 245, 255};  // 次背景色
static const rgb_color kAntNeutral4 = {240, 240, 240, 255};  // 边框色
static const rgb_color kAntNeutral5 = {217, 217, 217, 255};  // 分割线色
static const rgb_color kAntNeutral6 = {191, 191, 191, 255};  // 次文本色
static const rgb_color kAntNeutral7 = {140, 140, 140, 255};  // 文本色
static const rgb_color kAntNeutral8 = {89, 89, 89, 255};     // 标题色
static const rgb_color kAntNeutral9 = {54, 54, 54, 255};     // 深色文本
static const rgb_color kAntNeutral10 = {0, 0, 0, 255};       // 黑色

// Functional colors
static const rgb_color kAntSuccess = {82, 196, 26, 255};   // 成功色
static const rgb_color kAntWarning = {250, 173, 20, 255};  // 警告色
static const rgb_color kAntError = {245, 34, 45, 255};     // 错误色
static const rgb_color kAntInfo = {24, 144, 255, 255};     // 信息色

// Touch-friendly dimensions - 增加尺寸以适应触摸操作
static const float kAntTouchRadius = 6.0f;  // 圆角半径 - 增加圆角效果
static const float kAntTouchMinHeight = 36.0f;  // 最小高度 - 增加触摸区域
static const float kAntTouchDropdownHeight = 40.0f;  // 下拉框高度 - 专门为下拉框设计的更大高度
static const float kAntTouchMinWidth = 43.0f;  // 最小宽度 - 增加触摸区域
static const float kAntTouchPadding = 5.0f;  // 内边距 - 增加内部空间
static const float kAntTouchBorderWidth = 1.0f;        // 边框宽度
static const float kAntTouchFocusOutlineWidth = 2.0f;  // 焦点轮廓宽度

namespace BPrivate {

static const float kButtonPopUpIndicatorWidth = 11;

AntRedControlLook::AntRedControlLook(image_id id) : fCachedOutline(false) {
  // 初始化Ant Design风格
}

AntRedControlLook::~AntRedControlLook() {}

BAlignment AntRedControlLook::DefaultLabelAlignment() const {
  return BAlignment(B_ALIGN_LEFT, B_ALIGN_VERTICAL_CENTER);
}

float AntRedControlLook::DefaultLabelSpacing() const {
  // 增加标签间距以适应触摸操作
  return ceilf(be_plain_font->Size() * 0.75);
}

float AntRedControlLook::DefaultItemSpacing() const {
  // 增加项目间距以适应触摸操作
  return ceilf(be_plain_font->Size() * 1.2);
}

// 获取控件状态标志(完整Ant Design实现)
// 参数:
//   control - 需要获取状态的控件
// 返回值:
//   包含控件状态的标志位组合
uint32 AntRedControlLook::Flags(BControl* control) const {
  uint32 flags = B_IS_CONTROL;  // 基础标志，表示这是一个控件

  // 禁用状态处理
  if (!control->IsEnabled()) {
    flags |= B_DISABLED;  // 添加禁用标志
  }

  // 焦点状态处理
  if (control->IsFocus() && control->Window() != NULL &&
      control->Window()->IsActive()) {
    flags |= B_FOCUSED;  // 添加焦点标志
  }

  // 控件值状态处理
  switch (control->Value()) {
    case B_CONTROL_ON:
      flags |= B_ACTIVATED;  // 激活/选中状态
      break;
    case B_CONTROL_PARTIALLY_ON:
      flags |= B_PARTIALLY_ACTIVATED;  // 部分激活状态
      break;
  }

  // 父视图绘制处理
  if (control->Parent() != NULL &&
      (control->Parent()->Flags() & B_DRAW_ON_CHILDREN) != 0) {
    // 当父视图需要在子控件上绘制时，添加混合标志
    flags |= B_BLEND_FRAME;
  }

  // 点击状态检测(使用BControl::Value()变化来检测点击)
  static int32 lastValue = -1;
  int32 currentValue = control->Value();
  if (currentValue != lastValue && control->IsEnabled()) {
    flags |= B_CLICKED;  // 点击/按下状态
    lastValue = currentValue;
  }

  return flags;
}

void AntRedControlLook::DrawButtonFrame(BView* view, BRect& rect,
                                        const BRect& updateRect,
                                        const rgb_color& base,
                                        const rgb_color& background,
                                        uint32 flags, uint32 borders) {
  // 使用Ant Design风格的圆角半径
  _DrawButtonFrame(view, rect, updateRect, kAntTouchRadius, kAntTouchRadius,
                   kAntTouchRadius, kAntTouchRadius, base, background, 1.0, 1.0,
                   flags, borders);
}

void AntRedControlLook::DrawButtonFrame(BView* view, BRect& rect,
                                        const BRect& updateRect, float radius,
                                        const rgb_color& base,
                                        const rgb_color& background,
                                        uint32 flags, uint32 borders) {
  // 使用传入的圆角半径，但确保最小为触摸友好的尺寸
  float touchRadius = std::max(radius, kAntTouchRadius);
  _DrawButtonFrame(view, rect, updateRect, touchRadius, touchRadius,
                   touchRadius, touchRadius, base, background, 1.0, 1.0, flags,
                   borders);
}

void AntRedControlLook::DrawButtonFrame(
    BView* view, BRect& rect, const BRect& updateRect, float leftTopRadius,
    float rightTopRadius, float leftBottomRadius, float rightBottomRadius,
    const rgb_color& base, const rgb_color& background, uint32 flags,
    uint32 borders) {
  // 使用传入的各个角的圆角半径，但确保最小为触摸友好的尺寸
  float ltRadius = std::max(leftTopRadius, kAntTouchRadius);
  float rtRadius = std::max(rightTopRadius, kAntTouchRadius);
  float lbRadius = std::max(leftBottomRadius, kAntTouchRadius);
  float rbRadius = std::max(rightBottomRadius, kAntTouchRadius);

  _DrawButtonFrame(view, rect, updateRect, ltRadius, rtRadius, lbRadius,
                   rbRadius, base, background, 1.0, 1.0, flags, borders);
}

void AntRedControlLook::DrawButtonBackground(BView* view, BRect& rect,
                                             const BRect& updateRect,
                                             const rgb_color& base,
                                             uint32 flags, uint32 borders,
                                             orientation orientation) {
  // 使用Ant Design风格的圆角半径
  _DrawButtonBackground(view, rect, updateRect, kAntTouchRadius,
                        kAntTouchRadius, kAntTouchRadius, kAntTouchRadius, base,
                        false, flags, borders, orientation);
}

void AntRedControlLook::DrawButtonBackground(BView* view, BRect& rect,
                                             const BRect& updateRect,
                                             float radius,
                                             const rgb_color& base,
                                             uint32 flags, uint32 borders,
                                             orientation orientation) {
  // 使用传入的圆角半径，但确保最小为触摸友好的尺寸
  float touchRadius = std::max(radius, kAntTouchRadius);
  _DrawButtonBackground(view, rect, updateRect, touchRadius, touchRadius,
                        touchRadius, touchRadius, base, false, flags, borders,
                        orientation);
}

void AntRedControlLook::DrawButtonBackground(
    BView* view, BRect& rect, const BRect& updateRect, float leftTopRadius,
    float rightTopRadius, float leftBottomRadius, float rightBottomRadius,
    const rgb_color& base, uint32 flags, uint32 borders,
    orientation orientation) {
  // 使用传入的各个角的圆角半径，但确保最小为触摸友好的尺寸
  float ltRadius = std::max(leftTopRadius, kAntTouchRadius);
  float rtRadius = std::max(rightTopRadius, kAntTouchRadius);
  float lbRadius = std::max(leftBottomRadius, kAntTouchRadius);
  float rbRadius = std::max(rightBottomRadius, kAntTouchRadius);

  _DrawButtonBackground(view, rect, updateRect, ltRadius, rtRadius, lbRadius,
                        rbRadius, base, false, flags, borders, orientation);
}

// 绘制复选框(完整Ant Design实现)
// 参数:
//   view - 绘制目标视图
//   rect - 矩形区域(会被修改)
//   updateRect - 需要更新的区域
//   base - 基础颜色
//   flags - 控件状态标志(包含禁用状态等)
void AntRedControlLook::DrawCheckBox(BView* view, BRect& rect,
                                     const BRect& updateRect,
                                     const rgb_color& base, uint32 flags) {
  // 检查是否需要绘制
  if (!ShouldDraw(view, rect, updateRect)) return;

  view->PushState();

  // 控件状态
  bool isEnabled = (flags & B_DISABLED) == 0;
  bool isActivated = (flags & B_ACTIVATED) != 0;
  bool isFocused = (flags & B_FOCUSED) != 0;
  bool isPressed = (flags & B_CLICKED) != 0;
  bool isHovered = (flags & B_HOVER) != 0;

  // 确保复选框尺寸足够大，适合触摸操作
  float minSize = kAntTouchMinHeight * 0.6f;  // 复选框最小尺寸为触摸高度的60%
  if (rect.Width() < minSize || rect.Height() < minSize) {
    float centerX = (rect.left + rect.right) / 2;
    float centerY = (rect.top + rect.bottom) / 2;
    rect.left = centerX - minSize / 2;
    rect.right = centerX + minSize / 2;
    rect.top = centerY - minSize / 2;
    rect.bottom = centerY + minSize / 2;
  }

  // 保存原始矩形用于绘制焦点
  BRect originalRect = rect;

  // 使用Ant Design颜色方案
  rgb_color backgroundColor;
  rgb_color borderColor;
  rgb_color checkColor;

  if (!isEnabled) {
    // 禁用状态 - 使用中性色且降低透明度
    backgroundColor = tint_color(kAntNeutral3, 0.7f);
    borderColor = tint_color(kAntNeutral5, 0.7f);
    checkColor = tint_color(kAntNeutral6, 0.7f);
  } else if (isPressed) {
    // 按下状态 - 使用主色深色变体
    backgroundColor = kAntPrimaryDark;
    borderColor = kAntPrimaryDark;
    checkColor = kAntNeutral1;
  } else if (isActivated) {
    // 选中状态 - 使用主色
    backgroundColor = kAntPrimaryColor;
    borderColor = kAntPrimaryColor;
    checkColor = kAntNeutral1;  // 白色对勾
  } else if (isHovered) {
    // 悬停状态 - 使用主色浅色变体
    backgroundColor = kAntPrimaryLight;
    borderColor = kAntPrimaryLight;
    checkColor = kAntPrimaryColor;
  } else {
    // 默认状态 - 使用中性色
    backgroundColor = kAntNeutral1;
    borderColor = kAntNeutral5;
    checkColor = kAntPrimaryColor;
  }

  // 绘制背景(使用圆角效果)
  float radius = kAntTouchRadius * 0.5f;
  view->SetHighColor(backgroundColor);
  view->FillRoundRect(rect, radius, radius);

  // 绘制边框(使用圆角效果)
  view->SetHighColor(borderColor);
  view->SetPenSize(kAntTouchBorderWidth);
  view->StrokeRoundRect(rect, radius, radius);

  // 绘制对勾(选中状态)
  if (isActivated || isPressed) {
    // 计算对勾的尺寸和位置
    BRect checkRect =
        rect.InsetByCopy(rect.Width() * 0.25f, rect.Height() * 0.25f);

    // 设置绘制模式和颜色
    view->SetDrawingMode(B_OP_OVER);
    view->SetHighColor(checkColor);
    view->SetPenSize(std::max(2.0f, rect.Width() * 0.15f));  // 增加对勾线宽

    // 绘制对勾 (√) - 使用更平滑的曲线
    BPoint p1(checkRect.left, checkRect.top + checkRect.Height() * 0.5f);
    BPoint p2(checkRect.left + checkRect.Width() * 0.4f, checkRect.bottom);
    BPoint p3(checkRect.right, checkRect.top);

    view->StrokeLine(p1, p2);
    view->StrokeLine(p2, p3);

    // 恢复绘制模式
    view->SetDrawingMode(B_OP_COPY);
    view->SetPenSize(1.0f);
  }

  // 绘制焦点状态(使用更明显的轮廓)
  if (isEnabled && isFocused) {
    view->SetDrawingMode(B_OP_OVER);
    view->SetHighColor(kAntPrimaryLight);
    view->SetPenSize(kAntTouchFocusOutlineWidth);
    BRect focusRect = originalRect.InsetByCopy(-3, -3);
    view->StrokeRoundRect(focusRect, radius * 1.5f, radius * 1.5f);
    view->SetDrawingMode(B_OP_COPY);
    view->SetPenSize(1.0f);
  }

  // 绘制悬停状态效果
  if (isEnabled && isHovered && !isActivated && !isPressed) {
    // 使用半透明高亮效果
    rgb_color hoverColor = tint_color(kAntPrimaryLight, 0.2f);
    view->SetHighColor(hoverColor);
    view->SetDrawingMode(B_OP_ALPHA);
    view->FillRoundRect(rect, radius, radius);
    view->SetDrawingMode(B_OP_COPY);
  }

  view->PopState();
}

// 绘制单选按钮(完整Ant Design实现)
// 参数:
//   view - 绘制目标视图
//   rect - 矩形区域(会被修改)
//   updateRect - 需要更新的区域
//   base - 基础颜色
//   flags - 控件状态标志(包含禁用状态等)
void AntRedControlLook::DrawRadioButton(BView* view, BRect& rect,
                                        const BRect& updateRect,
                                        const rgb_color& base, uint32 flags) {
  // 检查是否需要绘制
  if (!ShouldDraw(view, rect, updateRect)) return;

  view->PushState();

  // 控件状态
  bool isEnabled = (flags & B_DISABLED) == 0;
  bool isActivated = (flags & B_ACTIVATED) != 0;
  bool isFocused = (flags & B_FOCUSED) != 0;
  bool isHovered = (flags & B_HOVER) != 0;
  bool isPressed = (flags & B_CLICKED) != 0;

  // 确保单选按钮尺寸足够大，适合触摸操作
  float minSize = kAntTouchMinHeight * 0.6f;  // 单选按钮最小尺寸为触摸高度的60%
  if (rect.Width() < minSize || rect.Height() < minSize) {
    float centerX = (rect.left + rect.right) / 2;
    float centerY = (rect.top + rect.bottom) / 2;
    rect.left = centerX - minSize / 2;
    rect.right = centerX + minSize / 2;
    rect.top = centerY - minSize / 2;
    rect.bottom = centerY + minSize / 2;
  }

  // 保存原始矩形用于绘制焦点
  BRect originalRect = rect;

  // 使用Ant Design颜色方案
  rgb_color borderColor;
  rgb_color backgroundColor;
  rgb_color dotColor;

  if (!isEnabled) {
    // 禁用状态 - 使用中性色且降低透明度
    borderColor = tint_color(kAntNeutral5, 0.7f);
    backgroundColor = tint_color(kAntNeutral3, 0.7f);
    dotColor = tint_color(kAntNeutral6, 0.7f);
  } else if (isPressed) {
    // 按下状态 - 使用主色深色变体
    borderColor = kAntPrimaryDark;
    backgroundColor = kAntPrimaryDark;
    dotColor = kAntNeutral1;
  } else if (isActivated) {
    // 选中状态 - 使用主色
    borderColor = kAntPrimaryColor;
    backgroundColor = kAntPrimaryColor;
    dotColor = kAntNeutral1;  // 白色圆点
  } else if (isHovered) {
    // 悬停状态 - 使用主色浅色变体
    borderColor = kAntPrimaryLight;
    backgroundColor = kAntNeutral2;
    dotColor = kAntPrimaryLight;
  } else {
    // 默认状态 - 使用中性色
    borderColor = kAntNeutral5;
    backgroundColor = kAntNeutral1;
    dotColor = kAntPrimaryColor;
  }

  // 绘制外圈(使用圆角效果)
  view->SetHighColor(backgroundColor);
  view->FillRoundRect(rect, minSize / 2, minSize / 2);

  // 绘制边框(使用圆角效果)
  view->SetHighColor(borderColor);
  view->SetPenSize(kAntTouchBorderWidth);
  view->StrokeRoundRect(rect, minSize / 2, minSize / 2);

  // 绘制内部圆点(选中状态)
  if (isActivated || isPressed) {
    // 计算内部圆点的尺寸和位置
    BRect dotRect = rect.InsetByCopy(rect.Width() * 0.3f, rect.Height() * 0.3f);

    // 设置绘制模式和颜色
    view->SetDrawingMode(B_OP_OVER);
    view->SetHighColor(dotColor);

    // 绘制圆点(使用圆角效果)
    view->FillRoundRect(dotRect, dotRect.Width() / 2, dotRect.Height() / 2);

    // 恢复绘制模式
    view->SetDrawingMode(B_OP_COPY);
  }

  // 绘制焦点状态(使用更明显的轮廓)
  if (isEnabled && isFocused) {
    view->SetDrawingMode(B_OP_OVER);
    view->SetHighColor(kAntPrimaryLight);
    view->SetPenSize(kAntTouchFocusOutlineWidth);
    BRect focusRect = originalRect.InsetByCopy(-3, -3);
    view->StrokeRoundRect(focusRect, minSize / 2 + kAntTouchFocusOutlineWidth,
                          minSize / 2 + kAntTouchFocusOutlineWidth);
    view->SetDrawingMode(B_OP_COPY);
    view->SetPenSize(1.0f);
  }

  view->PopState();
}

// 绘制滚动条边框(完整Ant Design实现)
// 参数:
//   view - 绘制目标视图
//   rect - 矩形区域
//   updateRect - 需要更新的区域
//   base - 基础颜色
//   flags - 控件状态标志(包含禁用状态等)
//   orientation - 滚动条方向
void AntRedControlLook::DrawScrollBarBorder(BView* view, BRect rect,
                                            const BRect& updateRect,
                                            const rgb_color& base, uint32 flags,
                                            orientation orientation) {
  // 检查是否需要绘制
  if (!ShouldDraw(view, rect, updateRect)) return;

  view->PushState();

  // 控件状态
  bool isEnabled = (flags & B_DISABLED) == 0;
  bool isFocused = (flags & B_FOCUSED) != 0;
  bool isHovered = (flags & B_HOVER) != 0;

  // 使用Ant Design颜色方案
  rgb_color borderColor;
  if (!isEnabled) {
    // 禁用状态 - 使用中性色且降低透明度
    borderColor = tint_color(kAntNeutral5, 0.7f);
  } else if (isFocused) {
    // 焦点状态 - 使用桃花缘主色
    borderColor = kAntPrimaryColor;
  } else if (isHovered) {
    // 悬停状态 - 使用浅色边框
    borderColor = tint_color(kAntPrimaryColor, B_LIGHTEN_1_TINT);
  } else {
    // 默认状态 - 使用中性色
    borderColor = kAntNeutral5;
  }

  // 增加触摸友好内边距
  rect.InsetBy(kAntTouchPadding / 4, kAntTouchPadding / 4);

  // 绘制圆角边框(使用Ant Design风格)
  view->SetHighColor(borderColor);
  view->SetPenSize(kAntTouchBorderWidth);
  view->StrokeRoundRect(rect, kAntTouchRadius, kAntTouchRadius);

  // 绘制焦点状态(使用更明显的轮廓)
  if (isEnabled && isFocused) {
    BRect focusRect = rect;
    focusRect.InsetBy(-kAntTouchFocusOutlineWidth, -kAntTouchFocusOutlineWidth);

    // 使用Ant Design主色作为焦点边框
    view->SetHighColor(kAntPrimaryColor);
    view->SetPenSize(kAntTouchFocusOutlineWidth);
    view->StrokeRoundRect(focusRect,
                          kAntTouchRadius + kAntTouchFocusOutlineWidth,
                          kAntTouchRadius + kAntTouchFocusOutlineWidth);
  }

  view->PopState();
}

// 绘制滚动条按钮(完整Ant Design实现)
// 参数:
//   view - 绘制目标视图
//   rect - 矩形区域
//   updateRect - 需要更新的区域
//   base - 基础颜色
//   flags - 控件状态标志(包含禁用状态等)
//   direction - 箭头方向
//   orientation - 滚动条方向
//   down - 按钮是否按下
void AntRedControlLook::DrawScrollBarButton(
    BView* view, BRect rect, const BRect& updateRect, const rgb_color& base,
    uint32 flags, int32 direction, orientation orientation, bool down) {
  // 检查是否需要绘制
  if (!ShouldDraw(view, rect, updateRect)) return;

  view->PushState();

  // 控件状态
  bool isEnabled = (flags & B_DISABLED) == 0;
  bool isHovered = (flags & B_HOVER) != 0;
  bool isPressed = down;

  // 使用Ant Design颜色方案
  rgb_color buttonColor;
  rgb_color borderColor;
  if (!isEnabled) {
    // 禁用状态 - 使用中性色且降低透明度
    buttonColor = tint_color(kAntNeutral5, 0.7f);
    borderColor = tint_color(kAntNeutral6, 0.7f);
  } else if (isPressed) {
    // 按下状态 - 使用主色深色变体
    buttonColor = kAntPrimaryDark;
    borderColor = tint_color(kAntPrimaryDark, B_DARKEN_1_TINT);
  } else if (isHovered) {
    // 悬停状态 - 使用主色浅色变体
    buttonColor = kAntPrimaryLight;
    borderColor = tint_color(kAntPrimaryLight, B_DARKEN_1_TINT);
  } else {
    // 默认状态 - 使用中性色
    buttonColor = kAntNeutral3;
    borderColor = kAntNeutral5;
  }

  // 确保按钮尺寸足够大，适合触摸操作
  float minSize = kAntTouchMinHeight * 0.6f;  // 按钮最小尺寸为触摸高度的60%
  if (orientation == B_VERTICAL) {
    if (rect.Width() < minSize) {
      float centerX = (rect.left + rect.right) / 2;
      rect.left = centerX - minSize / 2;
      rect.right = centerX + minSize / 2;
    }
  } else {
    if (rect.Height() < minSize) {
      float centerY = (rect.top + rect.bottom) / 2;
      rect.top = centerY - minSize / 2;
      rect.bottom = centerY + minSize / 2;
    }
  }

  // 绘制按钮背景(使用圆角效果)
  view->SetHighColor(buttonColor);
  view->FillRoundRect(rect, kAntTouchRadius, kAntTouchRadius);

  // 绘制按钮边框
  view->SetHighColor(borderColor);
  view->SetPenSize(kAntTouchBorderWidth);
  view->StrokeRoundRect(rect, kAntTouchRadius, kAntTouchRadius);

  // 绘制箭头(不使用DrawArrowShape，保持原有绘制方式)
  BRect arrowRect = rect;
  arrowRect.InsetBy(rect.Width() * 0.3f,
                    rect.Height() * 0.3f);  // 内缩30%作为箭头区域

  // 调整箭头方向以适应滚动条方向
  uint32 arrowDirection = direction;
  if (orientation == B_VERTICAL) {
    if (direction == B_LEFT_ARROW) arrowDirection = B_UP_ARROW;
    if (direction == B_RIGHT_ARROW) arrowDirection = B_DOWN_ARROW;
  }

  // 使用原有方式绘制箭头
  arrowRect.InsetBy(1, 1);
  arrowRect.OffsetBy(-3, -3);

  BPoint tri1, tri2, tri3;
  BPoint off1, off2, off3;
  BRect r(arrowRect.left, arrowRect.top, arrowRect.left + 14,
          arrowRect.top + 14);
  rgb_color lightenmax = tint_color(base, B_LIGHTEN_MAX_TINT);
  rgb_color light, dark, arrow, arrow2;

  switch (arrowDirection) {
    case B_LEFT_ARROW:
      tri1.Set(r.left + 3, floorf((r.top + r.bottom) / 2));
      tri2.Set(r.right - 4, r.top + 4);
      tri3.Set(r.right - 4, r.bottom - 4);
      break;

    default:
    case B_RIGHT_ARROW:
      tri1.Set(r.left + 4, r.bottom - 4);
      tri2.Set(r.left + 4, r.top + 4);
      tri3.Set(r.right - 3, floorf((r.top + r.bottom) / 2));
      break;

    case B_UP_ARROW:
      tri1.Set(r.left + 4, r.bottom - 4);
      tri2.Set(floorf((r.left + r.right) / 2), r.top + 3);
      tri3.Set(r.right - 4, r.bottom - 4);
      break;

    case B_DOWN_ARROW:
      tri1.Set(r.left + 4, r.top + 4);
      tri2.Set(r.right - 4, r.top + 4);
      tri3.Set(floorf((r.left + r.right) / 2), r.bottom - 3);
      break;
  }

  r.InsetBy(1, 1);

  float tint = B_NO_TINT;
  if (!isEnabled) tint = (tint + B_NO_TINT + B_NO_TINT) / 3;

  view->SetHighColor(tint_color(base, tint));
  view->MovePenTo(B_ORIGIN);
  view->SetDrawingMode(B_OP_OVER);

  if (isEnabled) {
    arrow2 = light = tint_color(base, B_DARKEN_2_TINT);
    dark = tint_color(base, B_DARKEN_3_TINT);
    arrow = tint_color(base, B_DARKEN_MAX_TINT);
  } else {
    arrow = arrow2 = light = dark = tint_color(base, B_DARKEN_1_TINT);
  }

  // 白色三角形偏移1px
  off1.Set(tri1.x + 1, tri1.y + 1);
  off2.Set(tri2.x + 1, tri2.y + 1);
  off3.Set(tri3.x + 1, tri3.y + 1);

  // 绘制白色三角形
  view->BeginLineArray(3);
  view->AddLine(off2, off3, lightenmax);
  view->AddLine(off1, off3, lightenmax);
  view->AddLine(off1, off2, lightenmax);
  view->EndLineArray();

  // 在上层绘制三角形
  view->BeginLineArray(3);
  view->AddLine(tri2, tri3, dark);
  view->AddLine(tri1, tri3, dark);
  view->AddLine(tri1, tri2, arrow2);
  view->EndLineArray();

  view->PopState();
}

void AntRedControlLook::DrawScrollBarBackground(
    BView* view, BRect& rect1, BRect& rect2, const BRect& updateRect,
    const rgb_color& base, uint32 flags, orientation orientation) {
  _DrawScrollBarBackgroundFirst(view, rect1, updateRect, base, flags,
                                orientation);
  _DrawScrollBarBackgroundSecond(view, rect2, updateRect, base, flags,
                                 orientation);
}

void AntRedControlLook::DrawScrollBarBackground(BView* view, BRect& rect,
                                                const BRect& updateRect,
                                                const rgb_color& base,
                                                uint32 flags,
                                                orientation orientation) {
  _DrawScrollBarBackgroundFirst(view, rect, updateRect, base, flags,
                                orientation);
}

// 绘制滚动条滑块(完整Ant Design实现)
// 参数:
//   view - 绘制目标视图
//   rect - 矩形区域(会被修改)
//   updateRect - 需要更新的区域
//   base - 基础颜色
//   flags - 控件状态标志(包含禁用状态等)
//   orientation - 方向(水平/垂直)
//   knobStyle - 滑块样式(点/线/无)
void AntRedControlLook::DrawScrollBarThumb(BView* view, BRect& rect,
                                           const BRect& updateRect,
                                           const rgb_color& base, uint32 flags,
                                           orientation orientation,
                                           uint32 knobStyle) {
  // 检查是否需要绘制
  if (!ShouldDraw(view, rect, updateRect)) return;

  view->PushState();

  // 控件状态
  bool isEnabled = (flags & B_DISABLED) == 0;
  bool isHovered = (flags & B_HOVER) != 0;
  bool isPressed = (flags & B_CLICKED) != 0;

  // 使用Ant Design颜色方案
  rgb_color thumbColor;
  if (!isEnabled) {
    // 禁用状态 - 使用中性色且降低透明度
    thumbColor = tint_color(kAntNeutral5, 0.7f);
  } else if (isPressed) {
    // 按下状态 - 使用主色深色变体
    thumbColor = kAntPrimaryDark;
  } else if (isHovered) {
    // 悬停状态 - 使用主色浅色变体
    thumbColor = kAntPrimaryLight;
  } else {
    // 默认状态 - 使用主色
    thumbColor = kAntPrimaryColor;
  }

  // 确保滑块尺寸足够大，适合触摸操作
  float minSize = kAntTouchMinHeight * 0.6f;  // 滑块最小尺寸为触摸高度的60%
  if (orientation == B_VERTICAL) {
    if (rect.Width() < minSize) {
      float centerX = (rect.left + rect.right) / 2;
      rect.left = centerX - minSize / 2;
      rect.right = centerX + minSize / 2;
    }
  } else {
    if (rect.Height() < minSize) {
      float centerY = (rect.top + rect.bottom) / 2;
      rect.top = centerY - minSize / 2;
      rect.bottom = centerY + minSize / 2;
    }
  }

  // 绘制滑块背景(使用圆角效果)
  view->SetHighColor(thumbColor);
  view->FillRoundRect(rect, kAntTouchRadius, kAntTouchRadius);

  // 绘制滑块边框
  rgb_color borderColor = isEnabled ? tint_color(thumbColor, B_DARKEN_1_TINT)
                                    : tint_color(kAntNeutral5, 0.7f);
  view->SetHighColor(borderColor);
  view->SetPenSize(kAntTouchBorderWidth);
  view->StrokeRoundRect(rect, kAntTouchRadius, kAntTouchRadius);

  // 绘制滑块指示器(点或线)
  if (knobStyle != B_KNOB_NONE) {
    float hcenter = rect.left + rect.Width() / 2;
    float vmiddle = rect.top + rect.Height() / 2;
    rgb_color knobDark = tint_color(thumbColor, B_DARKEN_1_TINT);
    rgb_color knobLight = tint_color(thumbColor, B_LIGHTEN_1_TINT);

    if (knobStyle == B_KNOB_DOTS) {
      // 中心点
      _DrawScrollBarKnobDot(view, hcenter, vmiddle, knobDark, knobLight,
                            orientation);

      // 根据方向绘制额外点
      if (orientation == B_HORIZONTAL) {
        float spacer = rect.Height();
        // 左侧点
        if (rect.left + 7 < hcenter - spacer) {
          _DrawScrollBarKnobDot(view, hcenter - 7, vmiddle, knobDark, knobLight,
                                orientation);
        }
        // 右侧点
        if (rect.right - 7 > hcenter + spacer) {
          _DrawScrollBarKnobDot(view, hcenter + 7, vmiddle, knobDark, knobLight,
                                orientation);
        }
      } else {
        float spacer = rect.Width();
        // 上方点
        if (rect.top + 7 < vmiddle - spacer) {
          _DrawScrollBarKnobDot(view, hcenter, vmiddle - 7, knobDark, knobLight,
                                orientation);
        }
        // 下方点
        if (rect.bottom - 7 > vmiddle + spacer) {
          _DrawScrollBarKnobDot(view, hcenter, vmiddle + 7, knobDark, knobLight,
                                orientation);
        }
      }
    } else if (knobStyle == B_KNOB_LINES) {
      // 中心线
      _DrawScrollBarKnobLine(view, hcenter, vmiddle, knobDark, knobLight,
                             orientation);

      // 根据方向绘制额外线
      if (orientation == B_HORIZONTAL) {
        float spacer = rect.Height();
        // 左侧线
        if (rect.left + 4 < hcenter - spacer) {
          _DrawScrollBarKnobLine(view, hcenter - 4, vmiddle, knobDark,
                                 knobLight, orientation);
        }
        // 右侧线
        if (rect.right - 4 > hcenter + spacer) {
          _DrawScrollBarKnobLine(view, hcenter + 4, vmiddle, knobDark,
                                 knobLight, orientation);
        }
      } else {
        float spacer = rect.Width();
        // 上方线
        if (rect.top + 4 < vmiddle - spacer) {
          _DrawScrollBarKnobLine(view, hcenter, vmiddle - 4, knobDark,
                                 knobLight, orientation);
        }
        // 下方线
        if (rect.bottom - 5 > vmiddle + spacer) {
          _DrawScrollBarKnobLine(view, hcenter, vmiddle + 4, knobDark,
                                 knobLight, orientation);
        }
      }
    }
  }

  view->PopState();
}

// 绘制滚动视图框架(完整Ant Design实现)
// 参数:
//   view - 绘制目标视图
//   rect - 矩形区域(会被修改)
//   updateRect - 需要更新的区域
//   verticalScrollBarFrame - 垂直滚动条框架
//   horizontalScrollBarFrame - 水平滚动条框架
//   base - 基础颜色
//   borderStyle - 边框样式
//   flags - 控件状态标志(包含禁用状态等)
//   _borders - 需要绘制的边框
void AntRedControlLook::DrawScrollViewFrame(BView* view, BRect& rect,
                                            const BRect& updateRect,
                                            BRect verticalScrollBarFrame,
                                            BRect horizontalScrollBarFrame,
                                            const rgb_color& base,
                                            border_style borderStyle,
                                            uint32 flags, uint32 _borders) {
  // 检查是否需要绘制
  if (!ShouldDraw(view, rect, updateRect)) return;

  view->PushState();

  // 控件状态
  bool isEnabled = (flags & B_DISABLED) == 0;
  bool isFocused = (flags & B_FOCUSED) != 0;
  bool isHovered = (flags & B_HOVER) != 0;

  // 使用Ant Design颜色方案
  rgb_color borderColor;
  if (!isEnabled) {
    // 禁用状态 - 使用中性色且降低透明度
    borderColor = tint_color(kAntNeutral5, 0.7f);
  } else if (isFocused) {
    // 焦点状态 - 使用桃花缘主色
    borderColor = kAntPrimaryColor;
  } else if (isHovered) {
    // 悬停状态 - 使用浅色边框
    borderColor = tint_color(kAntPrimaryColor, B_LIGHTEN_1_TINT);
  } else {
    // 默认状态 - 使用中性色
    borderColor = kAntNeutral5;
  }

  // 增加触摸友好内边距
  rect.InsetBy(kAntTouchPadding / 4, kAntTouchPadding / 4);

  // 绘制背景(使用Ant Design中性色)
  view->SetHighColor(kAntNeutral2);
  view->FillRoundRect(rect, kAntTouchRadius, kAntTouchRadius);

  // 绘制边框(使用圆角效果)
  view->SetHighColor(borderColor);
  view->SetPenSize(kAntTouchBorderWidth);
  view->StrokeRoundRect(rect, kAntTouchRadius, kAntTouchRadius);

  // 绘制焦点状态(使用更明显的轮廓)
  if (isEnabled && isFocused) {
    BRect focusRect = rect;
    focusRect.InsetBy(-kAntTouchFocusOutlineWidth, -kAntTouchFocusOutlineWidth);

    // 使用Ant Design主色作为焦点边框
    view->SetHighColor(kAntPrimaryColor);
    view->SetPenSize(kAntTouchFocusOutlineWidth);
    view->StrokeRoundRect(focusRect,
                          kAntTouchRadius + kAntTouchFocusOutlineWidth,
                          kAntTouchRadius + kAntTouchFocusOutlineWidth);
  }

  // 绘制滚动条区域(如果存在)
  if (verticalScrollBarFrame.Width() > 0 &&
      verticalScrollBarFrame.Height() > 0) {
    // 绘制垂直滚动条背景
    view->SetHighColor(kAntNeutral3);
    view->FillRoundRect(verticalScrollBarFrame, kAntTouchRadius,
                        kAntTouchRadius);
  }

  if (horizontalScrollBarFrame.Width() > 0 &&
      horizontalScrollBarFrame.Height() > 0) {
    // 绘制水平滚动条背景
    view->SetHighColor(kAntNeutral3);
    view->FillRoundRect(horizontalScrollBarFrame, kAntTouchRadius,
                        kAntTouchRadius);
  }

  view->PopState();
}

// 绘制箭头形状(完整Ant Design实现)
// 参数:
//   view - 绘制目标视图
//   rect - 矩形区域(会被修改)
//   updateRect - 需要更新的区域
//   base - 基础颜色
//   direction - 箭头方向(B_LEFT_ARROW/B_RIGHT_ARROW/B_UP_ARROW/B_DOWN_ARROW)
//   flags - 控件状态标志(包含禁用状态等)
//   tint - 颜色色调调整值
void AntRedControlLook::DrawArrowShape(BView* view, BRect& rect,
                                       const BRect& updateRect,
                                       const rgb_color& base, uint32 direction,
                                       uint32 flags, float tint) {
  // 检查是否需要绘制
  if (!ShouldDraw(view, rect, updateRect)) return;

  view->PushState();

  // 控件状态
  bool isEnabled = (flags & B_DISABLED) == 0;
  bool isHovered = (flags & B_HOVER) != 0;
  bool isPressed = (flags & B_CLICKED) != 0;

  // 使用Ant Design颜色方案
  rgb_color fillColor;
  rgb_color strokeColor;

  if (!isEnabled) {
    // 禁用状态 - 使用中性色且降低透明度
    fillColor = tint_color(kAntNeutral5, 0.7f);
    strokeColor = tint_color(kAntNeutral6, 0.7f);
  } else if (isPressed) {
    // 按下状态 - 使用主色深色变体
    fillColor = kAntPrimaryDark;
    strokeColor = tint_color(kAntPrimaryDark, B_DARKEN_1_TINT);
  } else if (isHovered) {
    // 悬停状态 - 使用主色浅色变体
    fillColor = kAntPrimaryLight;
    strokeColor = tint_color(kAntPrimaryLight, B_DARKEN_1_TINT);
  } else {
    // 默认状态 - 使用主色
    fillColor = kAntPrimaryColor;
    strokeColor = tint_color(kAntPrimaryColor, B_DARKEN_1_TINT);
  }

  // 增加触摸友好尺寸(扩大点击区域)
  float minSize = kAntTouchMinHeight * 0.5f;  // 箭头最小尺寸为触摸高度的一半
  if (rect.Width() < minSize || rect.Height() < minSize) {
    float centerX = (rect.left + rect.right) / 2;
    float centerY = (rect.top + rect.bottom) / 2;
    rect.left = centerX - minSize / 2;
    rect.right = centerX + minSize / 2;
    rect.top = centerY - minSize / 2;
    rect.bottom = centerY + minSize / 2;
  }

  // 计算箭头尺寸和位置(基于触摸友好尺寸)
  float arrowSize = minSize * 0.6f;  // 箭头大小为容器尺寸的60%
  float arrowOffset = (minSize - arrowSize) / 2;  // 居中偏移量

  switch (direction) {
    case B_LEFT_ARROW:
      // 左箭头 - 指向左侧的三角形
      view->SetHighColor(fillColor);
      view->FillTriangle(
          rect.LeftTop() + BPoint(arrowOffset + arrowSize, arrowOffset),
          rect.LeftTop() + BPoint(arrowOffset, arrowOffset + arrowSize / 2),
          rect.LeftTop() +
              BPoint(arrowOffset + arrowSize, arrowOffset + arrowSize));
      view->SetHighColor(strokeColor);
      view->StrokeTriangle(
          rect.LeftTop() + BPoint(arrowOffset + arrowSize, arrowOffset),
          rect.LeftTop() + BPoint(arrowOffset, arrowOffset + arrowSize / 2),
          rect.LeftTop() +
              BPoint(arrowOffset + arrowSize, arrowOffset + arrowSize));
      break;

    case B_RIGHT_ARROW:
      // 右箭头 - 指向右侧的三角形(默认方向)
      view->SetHighColor(fillColor);
      view->FillTriangle(
          rect.LeftTop() + BPoint(arrowOffset, arrowOffset),
          rect.LeftTop() + BPoint(arrowOffset, arrowOffset + arrowSize),
          rect.LeftTop() +
              BPoint(arrowOffset + arrowSize, arrowOffset + arrowSize / 2));
      view->SetHighColor(strokeColor);
      view->StrokeTriangle(
          rect.LeftTop() + BPoint(arrowOffset, arrowOffset),
          rect.LeftTop() + BPoint(arrowOffset, arrowOffset + arrowSize),
          rect.LeftTop() +
              BPoint(arrowOffset + arrowSize, arrowOffset + arrowSize / 2));
      break;

    case B_UP_ARROW:
      // 上箭头 - 指向顶部的三角形
      view->SetHighColor(fillColor);
      view->FillTriangle(
          rect.LeftTop() + BPoint(arrowOffset, arrowOffset + arrowSize),
          rect.LeftTop() + BPoint(arrowOffset + arrowSize / 2, arrowOffset),
          rect.LeftTop() +
              BPoint(arrowOffset + arrowSize, arrowOffset + arrowSize));
      view->SetHighColor(strokeColor);
      view->StrokeTriangle(
          rect.LeftTop() + BPoint(arrowOffset, arrowOffset + arrowSize),
          rect.LeftTop() + BPoint(arrowOffset + arrowSize / 2, arrowOffset),
          rect.LeftTop() +
              BPoint(arrowOffset + arrowSize, arrowOffset + arrowSize));
      break;

    case B_DOWN_ARROW:
      // 下箭头 - 指向底部的三角形
      view->SetHighColor(fillColor);
      view->FillTriangle(
          rect.LeftTop() + BPoint(arrowOffset, arrowOffset),
          rect.LeftTop() + BPoint(arrowOffset + arrowSize, arrowOffset),
          rect.LeftTop() +
              BPoint(arrowOffset + arrowSize / 2, arrowOffset + arrowSize));
      view->SetHighColor(strokeColor);
      view->StrokeTriangle(
          rect.LeftTop() + BPoint(arrowOffset, arrowOffset),
          rect.LeftTop() + BPoint(arrowOffset + arrowSize, arrowOffset),
          rect.LeftTop() +
              BPoint(arrowOffset + arrowSize / 2, arrowOffset + arrowSize));
      break;
  }

  view->PopState();
}

// 绘制菜单栏背景(完整Ant Design实现)
// 参数:
//   view - 绘制目标视图
//   rect - 矩形区域(会被修改)
//   updateRect - 需要更新的区域
//   base - 基础颜色
//   flags - 控件状态标志(包含禁用状态等)
//   borders - 需要绘制的边框
void AntRedControlLook::DrawMenuBarBackground(BView* view, BRect& rect,
                                              const BRect& updateRect,
                                              const rgb_color& base,
                                              uint32 flags, uint32 borders) {
  // 检查是否需要绘制
  if (!ShouldDraw(view, rect, updateRect)) return;

  view->PushState();

  // 使用Ant Design颜色方案
  rgb_color backgroundColor = kAntNeutral2;  // 使用中性色作为背景
  rgb_color topBorderColor = tint_color(
      kAntPrimaryColor, B_LIGHTEN_1_TINT);  // 顶部边框使用主色浅色变体
  rgb_color bottomBorderColor = tint_color(
      kAntPrimaryColor, B_DARKEN_1_TINT);  // 底部边框使用主色深色变体

  // 增加触摸友好高度(最小高度40px)
  if (rect.Height() < kAntTouchMinHeight) {
    rect.bottom = rect.top + kAntTouchMinHeight;
  }

  // 绘制背景(使用Ant Design中性色)
  view->SetHighColor(backgroundColor);
  view->FillRect(rect);

  // 绘制顶部边框(使用主色浅色变体)
  view->BeginLineArray(1);
  view->AddLine(rect.LeftTop(), rect.RightTop(), topBorderColor);
  view->EndLineArray();

  // 绘制底部边框(使用主色深色变体)
  view->BeginLineArray(1);
  view->AddLine(rect.LeftBottom(), rect.RightBottom(), bottomBorderColor);
  view->EndLineArray();

  // 绘制左右边框(如果指定了边框)
  if ((borders & B_LEFT_BORDER) != 0) {
    view->BeginLineArray(1);
    view->AddLine(rect.LeftTop(), rect.LeftBottom(), topBorderColor);
    view->EndLineArray();
  }

  if ((borders & B_RIGHT_BORDER) != 0) {
    view->BeginLineArray(1);
    view->AddLine(rect.RightTop(), rect.RightBottom(), bottomBorderColor);
    view->EndLineArray();
  }

  // 绘制阴影效果(增强立体感)
  view->BeginLineArray(2);
  // 左侧阴影
  view->AddLine(BPoint(rect.left + 1, rect.top + 1),
                BPoint(rect.left + 1, rect.bottom - 1),
                tint_color(kAntNeutral4, B_DARKEN_1_TINT));
  // 右侧高光
  view->AddLine(BPoint(rect.right - 1, rect.top + 1),
                BPoint(rect.right - 1, rect.bottom - 1),
                tint_color(kAntNeutral4, B_LIGHTEN_1_TINT));
  view->EndLineArray();

  view->PopState();
}

// 绘制菜单字段边框(完整Ant Design实现)
// 参数:
//   view - 绘制目标视图
//   rect - 矩形区域(会被修改)
//   updateRect - 需要更新的区域
//   base - 基础颜色
//   background - 背景颜色
//   flags - 控件状态标志(包含禁用状态等)
//   borders - 需要绘制的边框
void AntRedControlLook::DrawMenuFieldFrame(BView* view, BRect& rect,
                                           const BRect& updateRect,
                                           const rgb_color& base,
                                           const rgb_color& background,
                                           uint32 flags, uint32 borders) {
  
  DrawMenuFieldFrame(view, rect, updateRect, 0, base, background, flags,
                     borders);
}

// 绘制菜单字段边框(完整Ant Design实现)
// 参数:
//   view - 绘制目标视图
//   rect - 矩形区域(会被修改)
//   updateRect - 需要更新的区域
//   radius - 圆角半径(忽略)
//   base - 基础颜色
//   background - 背景颜色
//   flags - 控件状态标志(包含禁用状态等)
//   borders - 需要绘制的边框
void AntRedControlLook::DrawMenuFieldFrame(BView* view, BRect& rect,
                                           const BRect& updateRect, float,
                                           const rgb_color& base,
                                           const rgb_color& background,
                                           uint32 flags, uint32 borders) {
 
  DrawMenuFieldFrame(view, rect, updateRect, 0, 0, 0, 0, base, background,
                     flags, borders);
}

// 绘制菜单字段边框(完整Ant Design实现)
// 参数:
//   view - 绘制目标视图
//   rect - 矩形区域(会被修改)
//   updateRect - 需要更新的区域
//   leftTopRadius - 左上角圆角半径(忽略)
//   rightTopRadius - 右上角圆角半径(忽略)
//   leftBottomRadius - 左下角圆角半径(忽略)
//   rightBottomRadius - 右下角圆角半径(忽略)
//   base - 基础颜色
//   background - 背景颜色
//   flags - 控件状态标志(包含禁用状态等)
//   borders - 需要绘制的边框
void AntRedControlLook::DrawMenuFieldFrame(BView* view, BRect& rect,
                                           const BRect& updateRect, float,
                                           float, float, float,
                                           const rgb_color& base,
                                           const rgb_color& background,
                                           uint32 flags, uint32 borders) {
  // 检查是否需要绘制
  if (!ShouldDraw(view, rect, updateRect)) return;

  view->PushState();
  
  // 确保下拉框高度足够大，适合触摸操作
  if (rect.Height() < kAntTouchMinHeight) {
    float centerY = (rect.top + rect.bottom) / 2;
    rect.top = centerY - kAntTouchMinHeight / 2;
    rect.bottom = centerY + kAntTouchMinHeight / 2;
  }

  // 控件状态
  bool isEnabled = (flags & B_DISABLED) == 0;
  bool isFocused = (flags & B_FOCUSED) != 0;
  bool isHovered = (flags & B_HOVER) != 0;

  // 使用Ant Design颜色方案
  rgb_color borderColor;
  if (!isEnabled) {
    // 禁用状态 - 使用中性色且降低透明度
    borderColor = tint_color(kAntNeutral5, 0.7f);
  } else if (isFocused) {
    // 焦点状态 - 使用桃花缘主色
    borderColor = kAntPrimaryColor;
  } else if (isHovered) {
    // 悬停状态 - 使用浅色边框
    borderColor = tint_color(kAntPrimaryColor, B_LIGHTEN_1_TINT);
  } else {
    // 默认状态 - 使用中性色
    borderColor = kAntNeutral5;
  }

  // 增加触摸友好内边距
  rect.InsetBy(kAntTouchPadding / 4, kAntTouchPadding / 4);

  // 绘制圆角背景(使用Ant Design中性色)
  view->SetHighColor(background);
  view->FillRoundRect(rect, kAntTouchRadius, kAntTouchRadius);

  // 绘制边框(使用圆角效果)
  view->SetHighColor(borderColor);
  view->SetPenSize(kAntTouchBorderWidth);
  view->StrokeRoundRect(rect, kAntTouchRadius, kAntTouchRadius);

  // 绘制焦点状态(使用更明显的轮廓)
  if (isEnabled && isFocused) {
    BRect focusRect = rect;
    focusRect.InsetBy(-kAntTouchFocusOutlineWidth, -kAntTouchFocusOutlineWidth);

    // 使用Ant Design主色作为焦点边框
    view->SetHighColor(kAntPrimaryColor);
    view->SetPenSize(kAntTouchFocusOutlineWidth);
    view->StrokeRoundRect(focusRect,
                          kAntTouchRadius + kAntTouchFocusOutlineWidth,
                          kAntTouchRadius + kAntTouchFocusOutlineWidth);
  }

  // 绘制悬停状态效果
  if (isEnabled && isHovered) {
    // 使用半透明高亮效果
    rgb_color hoverColor = tint_color(kAntPrimaryColor, 0.2f);
    view->SetHighColor(hoverColor);
    view->SetDrawingMode(B_OP_ALPHA);
    view->FillRoundRect(rect, kAntTouchRadius, kAntTouchRadius);
    view->SetDrawingMode(B_OP_COPY);
  }

  view->PopState();
}

void AntRedControlLook::DrawMenuFieldBackground(BView* view, BRect& rect,
                                                const BRect& updateRect,
                                                const rgb_color& base,
                                                bool popupIndicator,
                                                uint32 flags) {
  _DrawMenuFieldBackgroundOutside(view, rect, updateRect, 0, 0, 0, 0, base,
                                  popupIndicator, flags);
}

void AntRedControlLook::DrawMenuFieldBackground(BView* view, BRect& rect,
                                                const BRect& updateRect,
                                                const rgb_color& base,
                                                uint32 flags, uint32 borders) {
  _DrawMenuFieldBackgroundInside(view, rect, updateRect, 0, 0, 0, 0, base,
                                 flags, borders);
}

void AntRedControlLook::DrawMenuFieldBackground(BView* view, BRect& rect,
                                                const BRect& updateRect, float,
                                                const rgb_color& base,
                                                bool popupIndicator,
                                                uint32 flags) {
  _DrawMenuFieldBackgroundOutside(view, rect, updateRect, 0, 0, 0, 0, base,
                                  popupIndicator, flags);
}

void AntRedControlLook::DrawMenuFieldBackground(
    BView* view, BRect& rect, const BRect& updateRect, float, float, float,
    float, const rgb_color& base, bool popupIndicator, uint32 flags) {
  _DrawMenuFieldBackgroundOutside(view, rect, updateRect, 0, 0, 0, 0, base,
                                  popupIndicator, flags);
}

// 绘制菜单背景(完整Ant Design实现)
// 参数:
//   view - 绘制目标视图
//   rect - 矩形区域(会被修改)
//   updateRect - 需要更新的区域
//   base - 基础颜色
//   flags - 控件状态标志(包含禁用状态等)
//   borders - 需要绘制的边框
void AntRedControlLook::DrawMenuBackground(BView* view, BRect& rect,
                                           const BRect& updateRect,
                                           const rgb_color& base, uint32 flags,
                                           uint32 borders) {
  // 检查是否需要绘制
  if (!ShouldDraw(view, rect, updateRect)) return;

  view->PushState();

  // 使用Ant Design颜色方案
  rgb_color backgroundColor = kAntNeutral2;  // 使用中性色作为背景
  rgb_color borderColor = kAntNeutral4;      // 使用中性色作为边框

  // 增加触摸友好内边距
  rect.InsetBy(kAntTouchPadding / 4, kAntTouchPadding / 4);

  // 绘制圆角背景
  view->SetHighColor(backgroundColor);
  view->FillRoundRect(rect, kAntTouchRadius, kAntTouchRadius);

  // 绘制阴影效果(增强立体感)
  view->BeginLineArray(4);
  // 顶部阴影
  view->AddLine(BPoint(rect.left, rect.top), BPoint(rect.right, rect.top),
                tint_color(borderColor, B_DARKEN_1_TINT));
  // 左侧阴影
  view->AddLine(BPoint(rect.left, rect.top + 1),
                BPoint(rect.left, rect.bottom - 1),
                tint_color(borderColor, B_DARKEN_1_TINT));
  // 右侧高光
  view->AddLine(BPoint(rect.right, rect.top + 1),
                BPoint(rect.right, rect.bottom - 1),
                tint_color(borderColor, B_LIGHTEN_1_TINT));
  // 底部高光
  view->AddLine(BPoint(rect.left + 1, rect.bottom),
                BPoint(rect.right - 1, rect.bottom),
                tint_color(borderColor, B_LIGHTEN_1_TINT));
  view->EndLineArray();

  // 绘制边框(使用圆角效果)
  view->SetHighColor(borderColor);
  view->SetPenSize(kAntTouchBorderWidth);
  view->StrokeRoundRect(rect, kAntTouchRadius, kAntTouchRadius);

  view->PopState();
}

// 绘制菜单项背景(完整Ant Design实现)
// 参数:
//   view - 绘制目标视图
//   rect - 矩形区域(会被修改)
//   updateRect - 需要更新的区域
//   base - 基础颜色
//   flags - 控件状态标志(包含禁用状态等)
//   borders - 需要绘制的边框
void AntRedControlLook::DrawMenuItemBackground(BView* view, BRect& rect,
                                               const BRect& updateRect,
                                               const rgb_color& base,
                                               uint32 flags, uint32 borders) {
  // 检查是否需要绘制
  if (!ShouldDraw(view, rect, updateRect)) return;

  view->PushState();

  // 使用Ant Design颜色方案
  rgb_color backgroundColor;
  rgb_color borderColor;
  bool isEnabled = (flags & B_DISABLED) == 0;
  bool isSelected = (flags & B_ACTIVATED) != 0;
  bool isHovered = (flags & B_HOVER) != 0;

  // 设置不同状态下的颜色
  if (!isEnabled) {
    // 禁用状态 - 使用中性色且降低透明度
    backgroundColor = tint_color(kAntNeutral3, 0.7f);
    borderColor = tint_color(kAntNeutral5, 0.7f);
  } else if (isSelected) {
    // 选中状态 - 使用桃花缘主色
    backgroundColor = tint_color(kAntPrimaryColor, 0.9f);
    borderColor = tint_color(kAntPrimaryColor, B_DARKEN_2_TINT);
  } else if (isHovered) {
    // 悬停状态 - 使用浅色变体
    backgroundColor = tint_color(kAntPrimaryLight, 0.6f);
    borderColor = tint_color(kAntPrimaryLight, B_DARKEN_1_TINT);
  } else {
    // 默认状态 - 使用中性色
    backgroundColor = kAntNeutral2;
    borderColor = kAntNeutral4;
  }

  // 增加触摸友好内边距
  rect.InsetBy(kAntTouchPadding / 4, kAntTouchPadding / 4);

  // 绘制圆角背景
  view->SetHighColor(backgroundColor);
  view->FillRoundRect(rect, kAntTouchRadius, kAntTouchRadius);

  // 绘制边框(如果处于选中或悬停状态)
  if (isSelected || isHovered) {
    view->SetHighColor(borderColor);
    view->SetPenSize(kAntTouchBorderWidth);
    view->StrokeRoundRect(rect, kAntTouchRadius, kAntTouchRadius);
  }

  // 绘制分隔线(如果指定了底部边框)
  if ((borders & B_BOTTOM_BORDER) != 0) {
    rgb_color dividerColor = tint_color(base, B_DARKEN_1_TINT);
    view->SetHighColor(dividerColor);
    view->StrokeLine(rect.LeftBottom(), rect.RightBottom());
  }

  view->PopState();
}

// 绘制状态栏(完整Ant Design实现)
// 参数:
//   view - 绘制目标视图
//   rect - 矩形区域(会被修改)
//   updateRect - 需要更新的区域
//   base - 基础颜色
//   barColor - 进度条颜色
//   progressPosition - 进度位置(0.0-1.0)
void AntRedControlLook::DrawStatusBar(BView* view, BRect& rect,
                                      const BRect& updateRect,
                                      const rgb_color& base,
                                      const rgb_color& barColor,
                                      float progressPosition) {
  // 检查是否需要绘制
  if (!ShouldDraw(view, rect, updateRect)) return;

  view->PushState();

  // 增加触摸友好高度(最小高度40px)
  if (rect.Height() < kAntTouchMinHeight / 2) {
    float centerY = (rect.top + rect.bottom) / 2;
    rect.top = centerY - kAntTouchMinHeight / 4;
    rect.bottom = centerY + kAntTouchMinHeight / 4;
  }

  // 使用Ant Design颜色方案
  rgb_color backgroundColor = kAntNeutral2;  // 背景使用中性色
  rgb_color borderColor = kAntNeutral4;      // 边框使用中性色

  // 绘制背景
  view->SetHighColor(backgroundColor);
  view->FillRect(rect);

  // 绘制圆角边框(使用Ant Design风格)
  view->SetHighColor(borderColor);
  view->SetPenSize(kAntTouchBorderWidth);
  view->StrokeRoundRect(rect, kAntTouchRadius, kAntTouchRadius);

  // 计算填充区域
  BRect filledRect = rect;
  filledRect.right = rect.left + (rect.Width() * progressPosition) - 1;
  filledRect.InsetBy(1, 1);  // 内缩1px避免覆盖边框

  // 计算未填充区域
  BRect nonfilledRect = rect;
  nonfilledRect.left = filledRect.right + 1;
  nonfilledRect.InsetBy(1, 1);  // 内缩1px避免覆盖边框

  // 绘制填充区域(使用渐变效果增强视觉层次)
  if (filledRect.Width() > 0) {
    // 创建渐变效果
    BGradientLinear gradient;
    gradient.AddColor(tint_color(barColor, B_LIGHTEN_1_TINT), 0);
    gradient.AddColor(barColor, 255);
    gradient.SetStart(filledRect.LeftTop());
    gradient.SetEnd(filledRect.LeftBottom());

    // 绘制渐变背景
    view->FillRect(filledRect, gradient);

    // 绘制内边框(增强立体感)
    view->SetHighColor(tint_color(barColor, B_DARKEN_1_TINT));
    view->StrokeRect(filledRect);
  }

  // 绘制未填充区域
  if (nonfilledRect.Width() > 0) {
    view->SetHighColor(kAntNeutral3);  // 使用更浅的中性色
    view->FillRect(nonfilledRect);
  }

  // 绘制进度文本(可选)
  if (progressPosition > 0) {
    BString progressText;
    progressText.SetToFormat("%d%%", (int)(progressPosition * 100));

    view->SetHighColor(kAntNeutral1);  // 白色文本
    view->SetLowColor(barColor);
    view->DrawString(progressText.String(),
                     BPoint(filledRect.right - 20, filledRect.top + 14));
  }

  view->PopState();
}

// 获取滑块轨道颜色(完整Ant Design实现)
// 参数:
//   base - 基础颜色
// 返回值:
//   返回滑块轨道的颜色，根据Ant Design规范实现
rgb_color AntRedControlLook::SliderBarColor(const rgb_color& base) {
  // 使用Ant Design中性色作为轨道基础色
  // 禁用状态使用kAntNeutral3(浅灰色)并降低透明度
  // 启用状态使用kAntNeutral4(更浅的灰色)作为轨道背景
  return tint_color(kAntNeutral4, B_DARKEN_1_TINT);
}

// 绘制滑块轨道(完整Ant Design实现)
// 参数:
//   view - 绘制目标视图
//   rect - 矩形区域
//   updateRect - 需要更新的区域
//   base - 基础颜色
//   leftFillColor - 左侧填充颜色
//   rightFillColor - 右侧填充颜色
//   sliderScale - 滑块位置比例(0.0-1.0)
//   flags - 控件状态标志(包含禁用状态等)
//   orientation - 方向(水平/垂直)
void AntRedControlLook::DrawSliderBar(
    BView* view, BRect rect, const BRect& updateRect, const rgb_color& base,
    rgb_color leftFillColor, rgb_color rightFillColor, float sliderScale,
    uint32 flags, orientation orientation) {
  // 检查是否需要绘制
  if (!ShouldDraw(view, rect, updateRect)) return;

  // 增加触摸友好尺寸(垂直滑块增加宽度，水平滑块增加高度)
  if (orientation == B_HORIZONTAL) {
    rect.InsetBy(0, (rect.Height() - kAntTouchPadding / 2) / 2);
  } else {
    rect.InsetBy((rect.Width() - kAntTouchPadding / 2) / 2, 0);
  }

  // 计算滑块分割位置
  float sliderPosition;
  BRect leftBarSide = rect;
  BRect rightBarSide = rect;

  if (orientation == B_HORIZONTAL) {
    // 水平滑块 - 从左到右计算位置
    sliderPosition = floorf(rect.left + kAntTouchPadding / 2 +
                            (rect.Width() - kAntTouchPadding) * sliderScale);
    leftBarSide.right = sliderPosition - 1;
    rightBarSide.left = sliderPosition;
  } else {
    // 垂直滑块 - 从下到上计算位置(反向坐标)
    sliderPosition =
        floorf(rect.top + kAntTouchPadding / 2 +
               (rect.Height() - kAntTouchPadding) * (1.0 - sliderScale));
    leftBarSide.top = sliderPosition;
    rightBarSide.bottom = sliderPosition - 1;
  }

  // 绘制左侧/上部轨道
  view->PushState();
  view->ClipToRect(leftBarSide);
  DrawSliderBar(view, rect, updateRect, base, leftFillColor, flags,
                orientation);
  view->PopState();

  // 绘制右侧/下部轨道
  view->PushState();
  view->ClipToRect(rightBarSide);
  DrawSliderBar(view, rect, updateRect, base, rightFillColor, flags,
                orientation);
  view->PopState();
}

// 绘制滑块轨道(完整Ant Design实现)
// 参数:
//   view - 绘制目标视图
//   rect - 矩形区域
//   updateRect - 需要更新的区域
//   base - 基础颜色
//   fillColor - 填充颜色
//   flags - 控件状态标志(包含禁用状态等)
//   orientation - 方向(水平/垂直)
void AntRedControlLook::DrawSliderBar(BView* view, BRect rect,
                                      const BRect& updateRect,
                                      const rgb_color& base,
                                      rgb_color fillColor, uint32 flags,
                                      orientation orientation) {
  // 检查是否需要绘制
  if (!ShouldDraw(view, rect, updateRect)) return;

  view->PushState();

  // 使用Ant Design颜色方案
  rgb_color trackColor;
  rgb_color borderColor;
  if ((flags & B_DISABLED) != 0) {
    // 禁用状态 - 使用中性色且降低透明度
    trackColor = tint_color(kAntNeutral3, 0.7f);
    borderColor = tint_color(kAntNeutral5, 0.7f);
  } else {
    // 启用状态 - 使用桃花缘主色
    trackColor = fillColor;
    borderColor = tint_color(kAntPrimaryColor, B_DARKEN_2_TINT);
  }

  // 增加触摸友好高度(垂直滑块)或宽度(水平滑块)
  if (orientation == B_HORIZONTAL) {
    rect.InsetBy(0, (rect.Height() - kAntTouchPadding / 4) / 2);
  } else {
    rect.InsetBy((rect.Width() - kAntTouchPadding / 4) / 2, 0);
  }

  // 绘制轨道背景
  view->SetHighColor(trackColor);
  view->FillRect(rect);

  // 绘制轨道边框(使用圆角效果)
  view->BeginLineArray(8);

  // 顶部边框
  view->AddLine(BPoint(rect.left, rect.top), BPoint(rect.right, rect.top),
                borderColor);

  // 底部边框
  view->AddLine(BPoint(rect.left, rect.bottom), BPoint(rect.right, rect.bottom),
                borderColor);

  // 左侧边框
  view->AddLine(BPoint(rect.left, rect.top + 1),
                BPoint(rect.left, rect.bottom - 1), borderColor);

  // 右侧边框
  view->AddLine(BPoint(rect.right, rect.top + 1),
                BPoint(rect.right, rect.bottom - 1), borderColor);

  // 绘制内阴影效果
  rgb_color innerShadow = tint_color(borderColor, B_LIGHTEN_1_TINT);
  view->AddLine(BPoint(rect.left + 1, rect.top + 1),
                BPoint(rect.right - 1, rect.top + 1), innerShadow);
  view->AddLine(BPoint(rect.left + 1, rect.top + 1),
                BPoint(rect.left + 1, rect.bottom - 1), innerShadow);

  // 绘制高光效果
  rgb_color highlight = tint_color(base, B_LIGHTEN_MAX_TINT);
  view->AddLine(BPoint(rect.left + 1, rect.bottom - 1),
                BPoint(rect.right - 1, rect.bottom - 1), highlight);
  view->AddLine(BPoint(rect.right - 1, rect.top + 1),
                BPoint(rect.right - 1, rect.bottom - 1), highlight);

  view->EndLineArray();

  // 绘制悬停/按下状态效果
  if ((flags & B_HOVER) != 0 || (flags & B_ACTIVATED) != 0) {
    rgb_color stateColor;
    if (flags & B_ACTIVATED) {
      // 按下状态 - 深色效果
      stateColor = tint_color(kAntPrimaryDark, 0.8f);
    } else {
      // 悬停状态 - 浅色效果
      stateColor = tint_color(kAntPrimaryLight, 0.6f);
    }

    // 绘制状态覆盖层(半透明)
    view->SetHighColor(stateColor);
    view->FillRect(rect.InsetByCopy(1, 1));
  }

  view->PopState();
}

// 绘制滑块拇指控件(完整Ant Design实现)
// 参数:
//   view - 绘制目标视图
//   rect - 矩形区域(会被修改)
//   updateRect - 需要更新的区域
//   base - 基础颜色
//   flags - 控件状态标志(包含禁用状态等)
//   orientation - 方向(水平/垂直)
void AntRedControlLook::DrawSliderThumb(BView* view, BRect& rect,
                                        const BRect& updateRect,
                                        const rgb_color& base, uint32 flags,
                                        orientation orientation) {
  // 检查是否需要绘制
  if (!ShouldDraw(view, rect, updateRect)) return;

  view->PushState();

  // 使用Ant Design颜色方案
  rgb_color thumbColor;
  rgb_color borderColor;
  if ((flags & B_DISABLED) != 0) {
    // 禁用状态 - 使用中性色且降低透明度
    thumbColor = tint_color(kAntNeutral5, 0.7f);
    borderColor = tint_color(kAntNeutral6, 0.7f);
  } else {
    // 启用状态 - 使用桃花缘主色
    thumbColor = kAntPrimaryColor;
    borderColor = tint_color(kAntPrimaryColor, B_DARKEN_2_TINT);
  }

  // 增加触摸友好尺寸(扩大点击区域)
  float touchPadding = kAntTouchPadding / 4;
  rect.InsetBy(-touchPadding, -touchPadding);

  // 绘制外边框(圆角矩形)
  view->SetHighColor(borderColor);
  view->FillRoundRect(rect, kAntTouchRadius, kAntTouchRadius);

  // 绘制内边框(缩小1px)
  BRect innerRect = rect.InsetByCopy(1, 1);
  view->SetHighColor(tint_color(borderColor, B_LIGHTEN_1_TINT));
  view->FillRoundRect(innerRect, kAntTouchRadius - 1, kAntTouchRadius - 1);

  // 绘制填充区域(缩小2px)
  BRect fillRect = rect.InsetByCopy(2, 2);
  view->SetHighColor(thumbColor);
  view->FillRoundRect(fillRect, kAntTouchRadius - 2, kAntTouchRadius - 2);

  // 绘制中心指示器(根据方向不同)
  float hCenter = fillRect.Width() / 2;
  float vMiddle = fillRect.Height() / 2;
  view->SetHighColor(tint_color(thumbColor, B_DARKEN_1_TINT));

  if (orientation == B_HORIZONTAL) {
    // 水平滑块 - 绘制3个垂直点
    view->FillEllipse(BPoint(fillRect.left + hCenter, fillRect.top + 3), 2, 2);
    view->FillEllipse(BPoint(fillRect.left + hCenter, fillRect.top + vMiddle),
                      2, 2);
    view->FillEllipse(BPoint(fillRect.left + hCenter, fillRect.bottom - 3), 2,
                      2);
  } else {
    // 垂直滑块 - 绘制3个水平点
    view->FillEllipse(BPoint(fillRect.left + 3, fillRect.top + vMiddle), 2, 2);
    view->FillEllipse(BPoint(fillRect.left + hCenter, fillRect.top + vMiddle),
                      2, 2);
    view->FillEllipse(BPoint(fillRect.right - 3, fillRect.top + vMiddle), 2, 2);
  }

  // 绘制悬停/按下状态效果
  if ((flags & B_HOVER) != 0 || (flags & B_ACTIVATED) != 0) {
    rgb_color stateColor;
    if (flags & B_ACTIVATED) {
      // 按下状态 - 深色效果
      stateColor = tint_color(kAntPrimaryDark, 0.8f);
    } else {
      // 悬停状态 - 浅色效果
      stateColor = tint_color(kAntPrimaryLight, 0.6f);
    }

    // 绘制状态覆盖层(半透明)
    view->SetHighColor(stateColor);
    view->FillRoundRect(fillRect, kAntTouchRadius - 2, kAntTouchRadius - 2);
  }

  view->PopState();
}

// 绘制滑块三角形指示器(完整Ant Design实现)
// 参数:
//   view - 绘制目标视图
//   rect - 矩形区域(会被修改)
//   updateRect - 需要更新的区域
//   base - 基础颜色
//   flags - 控件状态标志(包含禁用状态等)
//   orientation - 方向(水平/垂直)
void AntRedControlLook::DrawSliderTriangle(BView* view, BRect& rect,
                                           const BRect& updateRect,
                                           const rgb_color& base, uint32 flags,
                                           orientation orientation) {
  // 直接调用完整实现版本，使用base作为填充色
  // 这样可以保持代码一致性并避免重复实现
  DrawSliderTriangle(view, rect, updateRect, base, base, flags, orientation);
}

// 绘制滑块三角形指示器(完整Ant Design实现)
// 参数:
//   view - 绘制目标视图
//   rect - 矩形区域(会被修改)
//   updateRect - 需要更新的区域
//   base - 基础颜色
//   fill - 填充颜色
//   flags - 控件状态标志(包含禁用状态等)
//   orientation - 方向(水平/垂直)
void AntRedControlLook::DrawSliderTriangle(BView* view, BRect& rect,
                                           const BRect& updateRect,
                                           const rgb_color& base,
                                           const rgb_color& fill, uint32 flags,
                                           orientation orientation) {
  // 检查是否需要绘制
  if (!ShouldDraw(view, rect, updateRect)) return;

  view->PushState();

  // 使用Ant Design颜色方案
  rgb_color triangleColor;
  rgb_color borderColor;
  if ((flags & B_DISABLED) != 0) {
    // 禁用状态 - 使用中性色且降低透明度
    triangleColor = tint_color(kAntNeutral5, 0.7f);
    borderColor = tint_color(kAntNeutral6, 0.7f);
  } else {
    // 启用状态 - 使用桃花缘主色
    triangleColor = kAntPrimaryColor;
    borderColor = tint_color(kAntPrimaryColor, B_DARKEN_2_TINT);
  }

  // 增加触摸友好尺寸(扩大点击区域)
  float touchPadding = kAntTouchPadding / 4;
  rect.InsetBy(-touchPadding, -touchPadding);

  if (orientation == B_HORIZONTAL) {
    // 水平滑块 - 绘制向下指示三角形
    // 计算三角形顶点位置(考虑触摸友好尺寸)
    BPoint bottomLeft(rect.left + touchPadding, rect.bottom - 1 - touchPadding);
    BPoint topCenter(rect.left + rect.Width() / 2, rect.top + touchPadding);
    BPoint bottomRight(rect.right - touchPadding,
                       rect.bottom - 1 - touchPadding);

    // 绘制填充三角形(使用渐变效果增强立体感)
    BGradientLinear gradient;
    gradient.AddColor(triangleColor, 0);
    gradient.AddColor(tint_color(triangleColor, B_LIGHTEN_1_TINT), 255);
    gradient.SetStart(bottomLeft);
    gradient.SetEnd(topCenter);
    view->FillTriangle(bottomLeft, topCenter, bottomRight, gradient);

    // 绘制边框(分三边绘制，实现Ant Design的精细边框效果)
    view->BeginLineArray(3);
    // 左边框(较亮)
    view->AddLine(bottomLeft, topCenter,
                  tint_color(borderColor, B_LIGHTEN_1_TINT));
    // 右边框(较亮)
    view->AddLine(topCenter, bottomRight,
                  tint_color(borderColor, B_LIGHTEN_1_TINT));
    // 底边框(较暗)
    view->AddLine(bottomRight, bottomLeft, borderColor);
    view->EndLineArray();

    // 绘制内阴影效果(增强立体感)
    view->BeginLineArray(2);
    view->AddLine(BPoint(bottomLeft.x + 1, bottomLeft.y - 1),
                  BPoint(topCenter.x, topCenter.y + 1),
                  tint_color(base, B_LIGHTEN_2_TINT));
    view->AddLine(BPoint(topCenter.x, topCenter.y + 1),
                  BPoint(bottomRight.x - 1, bottomRight.y - 1),
                  tint_color(base, B_LIGHTEN_2_TINT));
    view->EndLineArray();
  } else {
    // 垂直滑块 - 绘制向右指示三角形
    // 计算三角形顶点位置(考虑触摸友好尺寸)
    BPoint topLeft(rect.left + touchPadding, rect.top + touchPadding);
    BPoint bottomLeft(rect.left + touchPadding, rect.bottom - touchPadding);
    BPoint rightCenter(rect.right - touchPadding, rect.top + rect.Height() / 2);

    // 绘制填充三角形(使用渐变效果增强立体感)
    BGradientLinear gradient;
    gradient.AddColor(triangleColor, 0);
    gradient.AddColor(tint_color(triangleColor, B_LIGHTEN_1_TINT), 255);
    gradient.SetStart(topLeft);
    gradient.SetEnd(rightCenter);
    view->FillTriangle(topLeft, bottomLeft, rightCenter, gradient);

    // 绘制边框(分三边绘制，实现Ant Design的精细边框效果)
    view->BeginLineArray(3);
    // 上边框(较亮)
    view->AddLine(topLeft, rightCenter,
                  tint_color(borderColor, B_LIGHTEN_1_TINT));
    // 下边框(较亮)
    view->AddLine(rightCenter, bottomLeft,
                  tint_color(borderColor, B_LIGHTEN_1_TINT));
    // 左边框(较暗)
    view->AddLine(bottomLeft, topLeft, borderColor);
    view->EndLineArray();

    // 绘制内阴影效果(增强立体感)
    view->BeginLineArray(2);
    view->AddLine(BPoint(topLeft.x + 1, topLeft.y + 1),
                  BPoint(rightCenter.x - 1, rightCenter.y),
                  tint_color(base, B_LIGHTEN_2_TINT));
    view->AddLine(BPoint(rightCenter.x - 1, rightCenter.y),
                  BPoint(bottomLeft.x + 1, bottomLeft.y - 1),
                  tint_color(base, B_LIGHTEN_2_TINT));
    view->EndLineArray();
  }

  // 绘制悬停/按下状态效果
  if ((flags & B_HOVER) != 0 || (flags & B_ACTIVATED) != 0) {
    rgb_color stateColor;
    if (flags & B_ACTIVATED) {
      // 按下状态 - 深色效果
      stateColor = tint_color(kAntPrimaryDark, 0.8f);
    } else {
      // 悬停状态 - 浅色效果
      stateColor = tint_color(kAntPrimaryLight, 0.6f);
    }

    // 根据方向绘制状态效果
    if (orientation == B_HORIZONTAL) {
      BRect stateRect = rect;
      stateRect.InsetBy(1, 1);
      stateRect.bottom -= 2;
      view->SetHighColor(stateColor);
      view->FillRect(stateRect);
    } else {
      BRect stateRect = rect;
      stateRect.InsetBy(1, 1);
      stateRect.right -= 2;
      view->SetHighColor(stateColor);
      view->FillRect(stateRect);
    }
  }

  view->PopState();
}

//----------------从此之后的代码为简化设计的代码---------------

// 绘制滑块刻度标记(根据Ant Design规范)
// 参数:
//   view - 绘制目标视图
//   rect - 矩形区域(会被修改)
//   updateRect - 需要更新的区域
//   base - 基础颜色
//   count - 刻度数量
//   location - 刻度位置(顶部/底部)
//   flags - 控件状态标志
//   orientation - 方向(水平/垂直)
void AntRedControlLook::DrawSliderHashMarks(BView* view, BRect& rect,
                                            const BRect& updateRect,
                                            const rgb_color& base, int32 count,
                                            hash_mark_location location,
                                            uint32 flags,
                                            orientation orientation) {
  // 检查是否需要绘制
  if (!ShouldDraw(view, rect, updateRect)) return;

  // 使用Ant Design颜色方案
  rgb_color markColor;
  if ((flags & B_DISABLED) != 0) {
    // 禁用状态使用中性色
    markColor = kAntNeutral5;
  } else {
    // 启用状态使用桃花缘主色
    markColor = kAntPrimaryColor;
  }

  // 确保至少绘制2个刻度(最小值和最大值)
  int32 hashMarkCount = std::max(count, (int32)2);

  // 计算刻度间距和起始位置
  float factor;
  float startPos;
  if (orientation == B_HORIZONTAL) {
    // 水平滑块 - 增加触摸友好间距
    factor = (rect.Width() - kAntTouchPadding) / (hashMarkCount - 1);
    startPos = rect.left + kAntTouchPadding / 2;
  } else {
    // 垂直滑块 - 增加触摸友好间距
    factor = (rect.Height() - kAntTouchPadding) / (hashMarkCount - 1);
    startPos = rect.top + kAntTouchPadding / 2;
  }

  // 绘制顶部/左侧刻度
  if (location & B_HASH_MARKS_TOP) {
    view->BeginLineArray(hashMarkCount);

    if (orientation == B_HORIZONTAL) {
      float pos = startPos;
      for (int32 i = 0; i < hashMarkCount; i++) {
        // 绘制刻度线(高度增加到6px)
        view->AddLine(BPoint(pos, rect.top), BPoint(pos, rect.top + 6),
                      markColor);
        pos += factor;
      }
    } else {
      float pos = startPos;
      for (int32 i = 0; i < hashMarkCount; i++) {
        // 绘制刻度线(宽度增加到6px)
        view->AddLine(BPoint(rect.left, pos), BPoint(rect.left + 6, pos),
                      markColor);
        pos += factor;
      }
    }

    view->EndLineArray();
  }

  // 绘制底部/右侧刻度
  if ((location & B_HASH_MARKS_BOTTOM) != 0) {
    view->BeginLineArray(hashMarkCount);

    if (orientation == B_HORIZONTAL) {
      float pos = startPos;
      for (int32 i = 0; i < hashMarkCount; i++) {
        // 绘制刻度线(高度增加到6px)
        view->AddLine(BPoint(pos, rect.bottom - 6), BPoint(pos, rect.bottom),
                      markColor);
        pos += factor;
      }
    } else {
      float pos = startPos;
      for (int32 i = 0; i < hashMarkCount; i++) {
        // 绘制刻度线(宽度增加到6px)
        view->AddLine(BPoint(rect.right - 6, pos), BPoint(rect.right, pos),
                      markColor);
        pos += factor;
      }
    }

    view->EndLineArray();
  }
}

// 绘制标签页框架(根据Ant Design规范)
// 参数:
//   view - 绘制目标视图
//   rect - 矩形区域(会被修改)
//   updateRect - 需要更新的区域
//   base - 基础颜色
//   flags - 控件状态标志
//   borders - 需要绘制的边框
//   borderStyle - 边框样式
//   side - 标签页位置(上/下/左/右)
void AntRedControlLook::DrawTabFrame(BView* view, BRect& rect,
                                     const BRect& updateRect,
                                     const rgb_color& base, uint32 flags,
                                     uint32 borders, border_style borderStyle,
                                     uint32 side) {
  // 检查是否需要绘制
  if (!ShouldDraw(view, rect, updateRect)) return;

  view->PushState();

  // 使用Ant Design颜色方案
  rgb_color frameColor;
  if ((flags & B_DISABLED) != 0) {
    // 禁用状态使用中性色
    frameColor = kAntNeutral4;
  } else {
    // 启用状态使用桃花缘主色
    frameColor = kAntPrimaryColor;
  }

  // 填充背景色
  view->SetHighColor(base);
  view->FillRect(rect);

  // 根据标签页位置绘制边框
  view->BeginLineArray(1);

  switch (side) {
    case BTabView::kLeftSide:  // 左侧标签页
      // 绘制右侧边框(增加触摸友好宽度)
      view->AddLine(BPoint(rect.right, rect.top),
                    BPoint(rect.right, rect.bottom), frameColor);
      break;

    case BTabView::kRightSide:  // 右侧标签页
      // 绘制左侧边框(增加触摸友好宽度)
      view->AddLine(BPoint(rect.left, rect.top), BPoint(rect.left, rect.bottom),
                    frameColor);
      break;

    default:
    case BTabView::kTopSide:  // 顶部标签页
      // 绘制底部边框(增加触摸友好宽度)
      view->AddLine(BPoint(rect.left, rect.bottom),
                    BPoint(rect.right, rect.bottom), frameColor);
      break;

    case BTabView::kBottomSide:  // 底部标签页
      // 绘制顶部边框(增加触摸友好宽度)
      view->AddLine(BPoint(rect.left, rect.top), BPoint(rect.right, rect.top),
                    frameColor);
      break;
  }

  view->EndLineArray();
  view->PopState();
}

// 绘制活动标签页(根据Ant Design规范)
// 参数:
//   view - 绘制目标视图
//   rect - 矩形区域(会被修改)
//   updateRect - 需要更新的区域
//   base - 基础颜色
//   flags - 控件状态标志
//   borders - 需要绘制的边框
//   side - 标签页位置(上/下/左/右)
void AntRedControlLook::DrawActiveTab(BView* view, BRect& rect,
                                      const BRect& updateRect,
                                      const rgb_color& base, uint32 flags,
                                      uint32 borders, uint32 side, int32, int32,
                                      int32, int32) {
  // 检查是否需要绘制
  if (!ShouldDraw(view, rect, updateRect)) return;

  view->PushState();

  // 增加触摸友好区域(扩大2px)
  view->ClipToRect(
      rect.InsetByCopy(-kAntTouchPadding / 8, -kAntTouchPadding / 8));

  // 使用Ant Design颜色方案
  rgb_color lightColor = kAntNeutral3;          // 浅色边框
  rgb_color darkColor = kAntNeutral5;           // 深色边框
  rgb_color highlightColor = kAntPrimaryColor;  // 高亮色(桃花缘主色)

  view->SetHighColor(darkColor);
  view->SetLowColor(base);

  // 开始绘制边框(12条线段)
  view->BeginLineArray(12);

  switch (side) {
    case BTabView::kLeftSide:  // 左侧标签页
      // 绘制顶部边框
      view->AddLine(BPoint(rect.right - 1, rect.top - 1),
                    BPoint(rect.right - 1, rect.top - 1), lightColor);
      view->AddLine(BPoint(rect.right - 2, rect.top),
                    BPoint(rect.right - 3, rect.top), lightColor);

      // 绘制左侧边框
      view->AddLine(BPoint(rect.right - 4, rect.top + 1),
                    BPoint(rect.left + 5, rect.top + 1), lightColor);

      // 绘制底部边框(左侧部分)
      view->AddLine(BPoint(rect.left + 2, rect.top + 2),
                    BPoint(rect.left + 4, rect.top + 2), lightColor);
      view->AddLine(BPoint(rect.left + 1, rect.top + 3),
                    BPoint(rect.left + 1, rect.top + 4), lightColor);

      // 绘制右侧边框
      view->AddLine(BPoint(rect.left, rect.top + 5),
                    BPoint(rect.left, rect.bottom - 5), lightColor);

      // 绘制底部边框(右侧部分)
      view->AddLine(BPoint(rect.left + 1, rect.bottom - 4),
                    BPoint(rect.left + 1, rect.bottom - 3), lightColor);
      view->AddLine(BPoint(rect.left + 2, rect.bottom - 2),
                    BPoint(rect.left + 3, rect.bottom - 2), darkColor);

      // 绘制底部边框
      view->AddLine(BPoint(rect.left + 4, rect.bottom - 1),
                    BPoint(rect.right - 4, rect.bottom - 1), darkColor);

      // 绘制右侧高亮边框
      view->AddLine(BPoint(rect.right - 3, rect.bottom),
                    BPoint(rect.right - 2, rect.bottom), highlightColor);
      view->AddLine(BPoint(rect.right - 1, rect.bottom + 1),
                    BPoint(rect.right - 1, rect.bottom + 1), highlightColor);
      view->AddLine(BPoint(rect.right, rect.bottom + 2),
                    BPoint(rect.right, rect.bottom + 2), highlightColor);
      break;

    case BTabView::kRightSide:
      // before going right
      view->AddLine(BPoint(rect.left - 1, rect.top - 1),
                    BPoint(rect.left - 1, rect.top - 1), lightColor);
      view->AddLine(BPoint(rect.left - 2, rect.top),
                    BPoint(rect.left - 3, rect.top), lightColor);

      // going right
      view->AddLine(BPoint(rect.left - 4, rect.top + 1),
                    BPoint(rect.right + 5, rect.top + 1), lightColor);

      // before going down
      view->AddLine(BPoint(rect.right + 2, rect.top + 2),
                    BPoint(rect.right + 4, rect.top + 2), lightColor);
      view->AddLine(BPoint(rect.right + 1, rect.top + 3),
                    BPoint(rect.right + 1, rect.top + 4), lightColor);

      // going down
      view->AddLine(BPoint(rect.right, rect.top + 5),
                    BPoint(rect.right, rect.bottom - 5), lightColor);

      // after going down
      view->AddLine(BPoint(rect.right + 1, rect.bottom - 4),
                    BPoint(rect.right + 1, rect.bottom - 3), lightColor);
      view->AddLine(BPoint(rect.right + 2, rect.bottom - 2),
                    BPoint(rect.right + 3, rect.bottom - 2), darkColor);

      // going left
      view->AddLine(BPoint(rect.right + 4, rect.bottom - 1),
                    BPoint(rect.left - 4, rect.bottom - 1), darkColor);

      // after going left
      view->AddLine(BPoint(rect.left - 3, rect.bottom),
                    BPoint(rect.left - 2, rect.bottom), highlightColor);
      view->AddLine(BPoint(rect.left - 1, rect.bottom + 1),
                    BPoint(rect.left - 1, rect.bottom + 1), highlightColor);
      view->AddLine(BPoint(rect.left, rect.bottom + 2),
                    BPoint(rect.left, rect.bottom + 2), highlightColor);
      break;

    default:
    case BTabView::kTopSide:
      // before going up
      view->AddLine(BPoint(rect.left - 1, rect.bottom - 1),
                    BPoint(rect.left - 1, rect.bottom - 1), lightColor);
      view->AddLine(BPoint(rect.left, rect.bottom - 2),
                    BPoint(rect.left, rect.bottom - 3), lightColor);

      // going up
      view->AddLine(BPoint(rect.left + 1, rect.bottom - 4),
                    BPoint(rect.left + 1, rect.top + 5), lightColor);

      // before going right
      view->AddLine(BPoint(rect.left + 2, rect.top + 4),
                    BPoint(rect.left + 2, rect.top + 2), lightColor);
      view->AddLine(BPoint(rect.left + 3, rect.top + 1),
                    BPoint(rect.left + 4, rect.top + 1), lightColor);

      // going right
      view->AddLine(BPoint(rect.left + 5, rect.top),
                    BPoint(rect.right - 5, rect.top), lightColor);

      // after going right
      view->AddLine(BPoint(rect.right - 4, rect.top + 1),
                    BPoint(rect.right - 3, rect.top + 1), lightColor);
      view->AddLine(BPoint(rect.right - 2, rect.top + 2),
                    BPoint(rect.right - 2, rect.top + 3), darkColor);

      // going down
      view->AddLine(BPoint(rect.right - 1, rect.top + 4),
                    BPoint(rect.right - 1, rect.bottom - 4), darkColor);

      // after going down
      view->AddLine(BPoint(rect.right, rect.bottom - 3),
                    BPoint(rect.right, rect.bottom - 2), highlightColor);
      view->AddLine(BPoint(rect.right + 1, rect.bottom - 1),
                    BPoint(rect.right + 1, rect.bottom - 1), highlightColor);
      view->AddLine(BPoint(rect.right + 2, rect.bottom),
                    BPoint(rect.right + 2, rect.bottom), highlightColor);
      break;

    case BTabView::kBottomSide:
      // before going down
      view->AddLine(BPoint(rect.left - 1, rect.top - 1),
                    BPoint(rect.left - 1, rect.top - 1), lightColor);
      view->AddLine(BPoint(rect.left, rect.top - 2),
                    BPoint(rect.left, rect.top - 3), lightColor);

      // going down
      view->AddLine(BPoint(rect.left + 1, rect.top - 4),
                    BPoint(rect.left + 1, rect.bottom + 5), lightColor);

      // before going right
      view->AddLine(BPoint(rect.left + 2, rect.bottom + 4),
                    BPoint(rect.left + 2, rect.bottom + 2), lightColor);
      view->AddLine(BPoint(rect.left + 3, rect.bottom + 1),
                    BPoint(rect.left + 4, rect.bottom + 1), lightColor);

      // going right
      view->AddLine(BPoint(rect.left + 5, rect.bottom),
                    BPoint(rect.right - 5, rect.bottom), lightColor);

      // after going right
      view->AddLine(BPoint(rect.right - 4, rect.bottom + 1),
                    BPoint(rect.right - 3, rect.bottom + 1), lightColor);
      view->AddLine(BPoint(rect.right - 2, rect.bottom + 2),
                    BPoint(rect.right - 2, rect.bottom + 3), darkColor);

      // going up
      view->AddLine(BPoint(rect.right - 1, rect.bottom + 4),
                    BPoint(rect.right - 1, rect.top - 4), darkColor);

      // after going up
      view->AddLine(BPoint(rect.right, rect.top - 3),
                    BPoint(rect.right, rect.top - 2), highlightColor);
      view->AddLine(BPoint(rect.right + 1, rect.top - 1),
                    BPoint(rect.right + 1, rect.top - 1), highlightColor);
      view->AddLine(BPoint(rect.right + 2, rect.top),
                    BPoint(rect.right + 2, rect.top), highlightColor);
      break;
  }
  view->EndLineArray();

  // undraw white line
  view->BeginLineArray(1);
  switch (side) {
    case BTabView::kLeftSide:
      view->AddLine(BPoint(rect.right, rect.top - 1),
                    BPoint(rect.right, rect.bottom + 1), base);
      break;

    case BTabView::kRightSide:
      view->AddLine(BPoint(rect.left, rect.top - 1),
                    BPoint(rect.left, rect.bottom + 1), base);
      break;

    default:
    case BTabView::kTopSide:
      view->AddLine(BPoint(rect.left - 1, rect.bottom),
                    BPoint(rect.right + 1, rect.bottom), base);
      break;

    case BTabView::kBottomSide:
      view->AddLine(BPoint(rect.left - 1, rect.top),
                    BPoint(rect.right + 1, rect.top), base);
      break;
  }
  view->EndLineArray();

  // 调整内容区域(增加内边距)
  rect.InsetBy(kAntTouchPadding / 8, kAntTouchPadding / 8);

  view->PopState();
}

// 绘制非活动标签页(根据Ant Design规范)
// 参数:
//   view - 绘制目标视图
//   rect - 矩形区域(会被修改)
//   updateRect - 需要更新的区域
//   base - 基础颜色
//   flags - 控件状态标志
//   borders - 需要绘制的边框
//   side - 标签页位置(上/下/左/右)
//   index - 当前标签页索引
//   selected - 选中标签页索引
//   first - 第一个标签页索引
//   last - 最后一个标签页索引
void AntRedControlLook::DrawInactiveTab(BView* view, BRect& rect,
                                        const BRect& updateRect,
                                        const rgb_color& base, uint32 flags,
                                        uint32 borders, uint32 side,
                                        int32 index, int32 selected,
                                        int32 first, int32 last) {
  // 检查是否需要绘制
  if (!ShouldDraw(view, rect, updateRect)) return;

  // 标签页状态
  bool isFirst = index == first;        // 是否是第一个标签页
  bool isFull = index != selected - 1;  // 是否不是选中标签页的前一个

  view->PushState();

  // 增加触摸友好区域(扩大2px)
  view->ClipToRect(
      rect.InsetByCopy(-kAntTouchPadding / 8, -kAntTouchPadding / 8));

  // 使用Ant Design颜色方案
  rgb_color lightColor = kAntNeutral3;          // 浅色边框
  rgb_color darkColor = kAntNeutral5;           // 深色边框
  rgb_color highlightColor = kAntPrimaryColor;  // 高亮色(桃花缘主色)

  view->SetHighColor(darkColor);
  view->SetLowColor(base);

  // 开始绘制边框(12条线段)
  view->BeginLineArray(12);

  switch (side) {
    case BTabView::kLeftSide:  // 左侧标签页
      // 如果是第一个标签页，绘制顶部边框
      if (isFirst) {
        // before going left
        view->AddLine(BPoint(rect.right - 1, rect.top - 1),
                      BPoint(rect.right - 1, rect.top - 1), lightColor);
        view->AddLine(BPoint(rect.right - 2, rect.top),
                      BPoint(rect.right - 3, rect.top), lightColor);
      }

      // 绘制左侧边框
      view->AddLine(BPoint(rect.right - 4, rect.top + 1),
                    BPoint(rect.left + 5, rect.top + 1), lightColor);

      // 绘制底部边框(左侧部分)
      view->AddLine(BPoint(rect.left + 2, rect.top + 2),
                    BPoint(rect.left + 4, rect.top + 2), lightColor);
      view->AddLine(BPoint(rect.left + 1, rect.top + 3),
                    BPoint(rect.left + 1, rect.top + 4), lightColor);

      // 绘制右侧边框
      view->AddLine(BPoint(rect.left, rect.top + 5),
                    BPoint(rect.left, rect.bottom - 5), lightColor);

      // 绘制底部边框(右侧部分)
      view->AddLine(BPoint(rect.left + 1, rect.bottom - 4),
                    BPoint(rect.left + 1, rect.bottom - 3), lightColor);
      view->AddLine(BPoint(rect.left + 2, rect.bottom - 2),
                    BPoint(rect.left + 3, rect.bottom - 2), darkColor);

      // 绘制底部边框
      view->AddLine(BPoint(rect.left + 4, rect.bottom - 1),
                    BPoint(rect.right - 4, rect.bottom - 1), darkColor);

      // 如果不是选中标签页的前一个，绘制右侧高亮边框
      if (isFull) {
        // after going right
        view->AddLine(BPoint(rect.right - 3, rect.bottom),
                      BPoint(rect.right - 2, rect.bottom), highlightColor);
        view->AddLine(BPoint(rect.right - 1, rect.bottom + 1),
                      BPoint(rect.right - 1, rect.bottom + 1), highlightColor);
      }
      break;

    case BTabView::kRightSide:
      // only draw if first tab is unselected
      if (isFirst) {
        // before going right
        view->AddLine(BPoint(rect.left - 1, rect.top - 1),
                      BPoint(rect.left - 1, rect.top - 1), lightColor);
        view->AddLine(BPoint(rect.left - 2, rect.top),
                      BPoint(rect.left - 3, rect.top), lightColor);
      }

      // going right
      view->AddLine(BPoint(rect.left - 4, rect.top + 1),
                    BPoint(rect.right + 5, rect.top + 1), lightColor);

      // before going down
      view->AddLine(BPoint(rect.right + 2, rect.top + 2),
                    BPoint(rect.right + 4, rect.top + 2), lightColor);
      view->AddLine(BPoint(rect.right + 1, rect.top + 3),
                    BPoint(rect.right + 1, rect.top + 4), lightColor);

      // going down
      view->AddLine(BPoint(rect.right, rect.top + 5),
                    BPoint(rect.right, rect.bottom - 5), lightColor);

      // after going down
      view->AddLine(BPoint(rect.right + 1, rect.bottom - 4),
                    BPoint(rect.right + 1, rect.bottom - 3), lightColor);
      view->AddLine(BPoint(rect.right + 2, rect.bottom - 2),
                    BPoint(rect.right + 3, rect.bottom - 2), darkColor);

      // going left
      view->AddLine(BPoint(rect.right + 4, rect.bottom - 1),
                    BPoint(rect.left - 4, rect.bottom - 1), darkColor);

      // only draw if not before selected tab
      if (isFull) {
        // after going left
        view->AddLine(BPoint(rect.left - 3, rect.bottom),
                      BPoint(rect.left - 2, rect.bottom), highlightColor);
        view->AddLine(BPoint(rect.left - 1, rect.bottom + 1),
                      BPoint(rect.left - 1, rect.bottom + 1), highlightColor);
      }
      break;

    default:
    case BTabView::kTopSide:
      // only draw if first tab is unselected
      if (isFirst) {
        // before going up
        view->AddLine(BPoint(rect.left - 1, rect.bottom - 1),
                      BPoint(rect.left - 1, rect.bottom - 1), lightColor);
        view->AddLine(BPoint(rect.left, rect.bottom - 2),
                      BPoint(rect.left, rect.bottom - 3), lightColor);
        ;
      }

      // going up
      view->AddLine(BPoint(rect.left + 1, rect.bottom - 4),
                    BPoint(rect.left + 1, rect.top + 5), lightColor);

      // before going right
      view->AddLine(BPoint(rect.left + 2, rect.top + 4),
                    BPoint(rect.left + 2, rect.top + 2), lightColor);
      view->AddLine(BPoint(rect.left + 3, rect.top + 1),
                    BPoint(rect.left + 4, rect.top + 1), lightColor);

      // going right
      view->AddLine(BPoint(rect.left + 5, rect.top),
                    BPoint(rect.right - 5, rect.top), lightColor);

      // after going right
      view->AddLine(BPoint(rect.right - 4, rect.top + 1),
                    BPoint(rect.right - 3, rect.top + 1), lightColor);
      view->AddLine(BPoint(rect.right - 2, rect.top + 2),
                    BPoint(rect.right - 2, rect.top + 3), darkColor);

      // going down
      view->AddLine(BPoint(rect.right - 1, rect.top + 4),
                    BPoint(rect.right - 1, rect.bottom - 4), darkColor);

      // only draw if not before selected tab
      if (isFull) {
        // after going down
        view->AddLine(BPoint(rect.right, rect.bottom - 3),
                      BPoint(rect.right, rect.bottom - 2), highlightColor);
        view->AddLine(BPoint(rect.right + 1, rect.bottom - 1),
                      BPoint(rect.right + 1, rect.bottom - 1), highlightColor);
      }
      break;

    case BTabView::kBottomSide:
      // only draw if first tab is unselected
      if (isFirst) {
        // before going down
        view->AddLine(BPoint(rect.left - 1, rect.top - 1),
                      BPoint(rect.left - 1, rect.top - 1), lightColor);
        view->AddLine(BPoint(rect.left, rect.top - 2),
                      BPoint(rect.left, rect.top - 3), lightColor);
      }

      // before going down
      view->AddLine(BPoint(rect.left + 1, rect.top - 4),
                    BPoint(rect.left + 1, rect.bottom + 5), lightColor);

      // before going right
      view->AddLine(BPoint(rect.left + 2, rect.bottom + 4),
                    BPoint(rect.left + 2, rect.bottom + 2), lightColor);
      view->AddLine(BPoint(rect.left + 3, rect.bottom + 1),
                    BPoint(rect.left + 4, rect.bottom + 1), lightColor);

      // going right
      view->AddLine(BPoint(rect.left + 5, rect.bottom),
                    BPoint(rect.right - 5, rect.bottom), lightColor);

      // after going right
      view->AddLine(BPoint(rect.right - 4, rect.bottom + 1),
                    BPoint(rect.right - 3, rect.bottom + 1), lightColor);
      view->AddLine(BPoint(rect.right - 2, rect.bottom + 2),
                    BPoint(rect.right - 2, rect.bottom + 3), darkColor);

      // going up
      view->AddLine(BPoint(rect.right - 1, rect.bottom + 4),
                    BPoint(rect.right - 1, rect.top - 4), darkColor);

      // only draw if not before selected tab
      if (isFull) {
        // after going up
        view->AddLine(BPoint(rect.right, rect.top - 3),
                      BPoint(rect.right, rect.top - 2), highlightColor);
        view->AddLine(BPoint(rect.right + 1, rect.top - 1),
                      BPoint(rect.right + 1, rect.top - 1), highlightColor);
      }
      break;
  }

  view->EndLineArray();

  // 调整内容区域(增加内边距)
  rect.InsetBy(kAntTouchPadding / 8, kAntTouchPadding / 8);

  view->PopState();
}

// 绘制分割线控件(根据Ant Design规范)
// 参数:
//   view - 绘制目标视图
//   rect - 矩形区域(会被修改)
//   updateRect - 需要更新的区域
//   base - 基础颜色
//   orientation - 方向(水平/垂直)
//   flags - 控件状态标志
//   borders - 需要绘制的边框
void AntRedControlLook::DrawSplitter(BView* view, BRect& rect,
                                     const BRect& updateRect,
                                     const rgb_color& base,
                                     orientation orientation, uint32 flags,
                                     uint32 borders) {
  // 检查是否需要绘制
  if (!ShouldDraw(view, rect, updateRect)) return;

  // 使用Ant Design颜色方案
  rgb_color background;
  if ((flags & (B_CLICKED | B_ACTIVATED)) != 0) {
    // 激活状态使用深色背景
    background = tint_color(base, B_DARKEN_1_TINT);
  } else {
    // 默认状态使用中性背景色
    background = kAntNeutral4;
  }

  // 绘制边框(如果指定了边框)
  if (borders != 0 && rect.Width() > 3 && rect.Height() > 3) {
    // 使用Ant Design风格的边框
    DrawBorder(view, rect, updateRect, background, B_PLAIN_BORDER, flags,
               borders);
  }

  // 根据方向绘制分割线点阵
  if (orientation == B_HORIZONTAL) {
    // 水平分割线 - 计算中心位置
    float center = floorf((rect.left + rect.right) / 2.0 - 0.5);

    // 创建点阵区域(增加触摸友好间距)
    BRect dotRect(center, rect.top, center + 1, rect.bottom);
    dotRect.InsetBy(0, kAntTouchPadding / 4);  // 上下增加内边距

    // 绘制背景区域
    BRegion region(rect);
    region.Exclude(dotRect);
    view->SetHighColor(background);
    view->FillRegion(&region);

    // 绘制点阵(使用Ant Design风格的点)
    view->BeginLineArray(8);
    BPoint dot = dotRect.LeftTop();
    BPoint stop = dotRect.LeftBottom();

    // 使用桃花缘主色作为点阵颜色
    rgb_color dotColor = kAntPrimaryColor;
    rgb_color dotShadow = tint_color(dotColor, B_DARKEN_1_TINT);

    while (dot.y <= stop.y) {
      // 每隔3像素绘制一个点
      if ((int)dot.y % 3 == 0) {
        view->AddLine(dot, dot, dotColor);
        view->AddLine(BPoint(dot.x + 1, dot.y), BPoint(dot.x + 1, dot.y),
                      dotShadow);
      }
      dot.y++;
    }
    view->EndLineArray();
  } else {
    // 垂直分割线 - 计算中心位置
    float center = floorf((rect.top + rect.bottom) / 2.0 - 0.5);

    // 创建点阵区域(增加触摸友好间距)
    BRect dotRect(rect.left, center, rect.right, center + 1);
    dotRect.InsetBy(kAntTouchPadding / 4, 0);  // 左右增加内边距

    // 绘制背景区域
    BRegion region(rect);
    region.Exclude(dotRect);
    view->SetHighColor(background);
    view->FillRegion(&region);

    // 绘制点阵(使用Ant Design风格的点)
    view->BeginLineArray(8);
    BPoint dot = dotRect.LeftTop();
    BPoint stop = dotRect.RightTop();

    // 使用桃花缘主色作为点阵颜色
    rgb_color dotColor = kAntPrimaryColor;
    rgb_color dotShadow = tint_color(dotColor, B_DARKEN_1_TINT);

    while (dot.x <= stop.x) {
      // 每隔3像素绘制一个点
      if ((int)dot.x % 3 == 0) {
        view->AddLine(dot, dot, dotColor);
        view->AddLine(BPoint(dot.x, dot.y + 1), BPoint(dot.x, dot.y + 1),
                      dotShadow);
      }
      dot.x++;
    }
    view->EndLineArray();
  }
}

//	#pragma mark - various borders

// 绘制边框(根据Ant Design规范)
// 参数:
//   view - 绘制目标视图
//   rect - 矩形区域(会被修改)
//   updateRect - 需要更新的区域
//   base - 基础颜色
//   borderStyle - 边框样式
//   flags - 控件状态标志
//   borders - 需要绘制的边框
void AntRedControlLook::DrawBorder(BView* view, BRect& rect,
                                   const BRect& updateRect,
                                   const rgb_color& base,
                                   border_style borderStyle, uint32 flags,
                                   uint32 borders) {
  // 无边框样式直接返回
  if (borderStyle == B_NO_BORDER) return;

  // 检查是否需要绘制
  if (!ShouldDraw(view, rect, updateRect)) return;

  view->PushState();
  view->ClipToRect(rect);

  // 使用Ant Design颜色方案
  rgb_color lightColor;
  rgb_color shadowColor;

  if ((flags & B_DISABLED) != 0) {
    // 禁用状态使用中性色
    lightColor = kAntNeutral4;
    shadowColor = kAntNeutral4;
  } else if (base.IsLight()) {
    // 浅色背景使用深色边框
    lightColor = kAntNeutral5;   // 浅色边框
    shadowColor = kAntNeutral6;  // 深色边框
  } else {
    // 深色背景使用浅色边框
    lightColor = kAntNeutral3;   // 浅色边框
    shadowColor = kAntNeutral7;  // 深色边框
  }

  // 使用触摸友好的边框宽度
  const float borderWidth = kAntTouchBorderWidth;

  // 开始绘制边框
  view->BeginLineArray(8);

  if (borderStyle == B_FANCY_BORDER) {
    // 绘制外边框(深色部分)
    if ((borders & B_LEFT_BORDER) != 0) {
      view->AddLine(rect.LeftBottom(), rect.LeftTop(), shadowColor);
      rect.left += borderWidth;
    }
    if ((borders & B_TOP_BORDER) != 0) {
      view->AddLine(rect.LeftTop(), rect.RightTop(), shadowColor);
      rect.top += borderWidth;
    }
    if ((borders & B_RIGHT_BORDER) != 0) {
      view->AddLine(rect.RightTop(), rect.RightBottom(), shadowColor);
      rect.right -= borderWidth;
    }
    if ((borders & B_BOTTOM_BORDER) != 0) {
      view->AddLine(rect.RightBottom(), rect.LeftBottom(), shadowColor);
      rect.bottom -= borderWidth;
    }

    // 绘制内边框(浅色部分)
    if ((borders & B_LEFT_BORDER) != 0) {
      view->AddLine(rect.LeftBottom(), rect.LeftTop(), lightColor);
      rect.left += borderWidth;
    }
    if ((borders & B_TOP_BORDER) != 0) {
      view->AddLine(rect.LeftTop(), rect.RightTop(), lightColor);
      rect.top += borderWidth;
    }
    if ((borders & B_RIGHT_BORDER) != 0) {
      view->AddLine(rect.RightTop(), rect.RightBottom(), lightColor);
      rect.right -= borderWidth;
    }
    if ((borders & B_BOTTOM_BORDER) != 0) {
      view->AddLine(rect.RightBottom(), rect.LeftBottom(), lightColor);
      rect.bottom -= borderWidth;
    }
  } else if (borderStyle == B_PLAIN_BORDER) {
    // 简单边框只绘制单层
    if ((borders & B_LEFT_BORDER) != 0) {
      view->AddLine(rect.LeftBottom(), rect.LeftTop(), shadowColor);
      rect.left += borderWidth;
    }
    if ((borders & B_TOP_BORDER) != 0) {
      view->AddLine(rect.LeftTop(), rect.RightTop(), shadowColor);
      rect.top += borderWidth;
    }
    if ((borders & B_RIGHT_BORDER) != 0) {
      view->AddLine(rect.RightTop(), rect.RightBottom(), shadowColor);
      rect.right -= borderWidth;
    }
    if ((borders & B_BOTTOM_BORDER) != 0) {
      view->AddLine(rect.RightBottom(), rect.LeftBottom(), shadowColor);
      rect.bottom -= borderWidth;
    }
  }

  view->EndLineArray();
  view->PopState();
}

// 绘制凸起边框(根据Ant Design规范)
// 参数:
//   view - 绘制目标视图
//   rect - 矩形区域(会被修改)
//   updateRect - 需要更新的区域
//   base - 基础颜色
//   flags - 控件状态标志
//   borders - 需要绘制的边框
void AntRedControlLook::DrawRaisedBorder(BView* view, BRect& rect,
                                         const BRect& updateRect,
                                         const rgb_color& base, uint32 flags,
                                         uint32 borders) {
  // 检查是否需要绘制
  if (!ShouldDraw(view, rect, updateRect)) return;

  view->PushState();
  view->ClipToRect(rect);

  // 使用Ant Design颜色方案
  rgb_color lightColor;
  rgb_color shadowColor;

  if ((flags & B_DISABLED) != 0) {
    // 禁用状态使用中性色
    lightColor = kAntNeutral4;
    shadowColor = kAntNeutral4;
  } else {
    // 启用状态使用Ant Design阴影效果
    lightColor = tint_color(base, B_LIGHTEN_1_TINT);  // 浅色边框
    shadowColor = tint_color(base, B_DARKEN_1_TINT);  // 深色边框
  }

  // 使用触摸友好的边框宽度
  const float borderWidth = kAntTouchBorderWidth;

  // 绘制边框
  view->BeginLineArray(8);

  // 左侧边框
  if ((borders & B_LEFT_BORDER) != 0) {
    view->AddLine(BPoint(rect.left, rect.top), BPoint(rect.left, rect.bottom),
                  lightColor);
    rect.left += borderWidth;
  }

  // 顶部边框
  if ((borders & B_TOP_BORDER) != 0) {
    view->AddLine(BPoint(rect.left, rect.top), BPoint(rect.right, rect.top),
                  lightColor);
    rect.top += borderWidth;
  }

  // 右侧边框
  if ((borders & B_RIGHT_BORDER) != 0) {
    view->AddLine(BPoint(rect.right, rect.top), BPoint(rect.right, rect.bottom),
                  shadowColor);
    rect.right -= borderWidth;
  }

  // 底部边框
  if ((borders & B_BOTTOM_BORDER) != 0) {
    view->AddLine(BPoint(rect.left, rect.bottom),
                  BPoint(rect.right, rect.bottom), shadowColor);
    rect.bottom -= borderWidth;
  }

  // 内部边框 - 增强3D效果
  if ((borders & B_LEFT_BORDER) != 0) {
    view->AddLine(BPoint(rect.left, rect.top), BPoint(rect.left, rect.bottom),
                  tint_color(lightColor, B_LIGHTEN_1_TINT));
    rect.left += borderWidth;
  }

  if ((borders & B_TOP_BORDER) != 0) {
    view->AddLine(BPoint(rect.left, rect.top), BPoint(rect.right, rect.top),
                  tint_color(lightColor, B_LIGHTEN_1_TINT));
    rect.top += borderWidth;
  }

  if ((borders & B_RIGHT_BORDER) != 0) {
    view->AddLine(BPoint(rect.right, rect.top), BPoint(rect.right, rect.bottom),
                  tint_color(shadowColor, B_DARKEN_1_TINT));
    rect.right -= borderWidth;
  }

  if ((borders & B_BOTTOM_BORDER) != 0) {
    view->AddLine(BPoint(rect.left, rect.bottom),
                  BPoint(rect.right, rect.bottom),
                  tint_color(shadowColor, B_DARKEN_1_TINT));
    rect.bottom -= borderWidth;
  }

  view->EndLineArray();

  view->PopState();
}

// 绘制文本控件边框(根据Ant Design规范)
// 参数:
//   view - 绘制目标视图
//   rect - 矩形区域(会被修改)
//   updateRect - 需要更新的区域
//   base - 基础颜色
//   flags - 控件状态标志
//   borders - 需要绘制的边框
void AntRedControlLook::DrawTextControlBorder(BView* view, BRect& rect,
                                              const BRect& updateRect,
                                              const rgb_color& base,
                                              uint32 flags, uint32 borders) {
  // 检查是否需要绘制
  if (!ShouldDraw(view, rect, updateRect)) return;

  view->PushState();
  view->ClipToRect(rect);

  // 控件状态
  bool isEnabled = (flags & B_DISABLED) == 0;
  bool isFocused = (flags & B_FOCUSED) != 0;

  // 使用Ant Design颜色方案
  rgb_color borderColor = isEnabled ? kAntNeutral5 : kAntNeutral4;  // 边框颜色
  rgb_color focusColor = kAntPrimaryColor;  // 焦点状态使用桃花缘主色

  // 绘制外边框
  view->BeginLineArray(4);

  // 左侧边框
  if ((borders & B_LEFT_BORDER) != 0) {
    view->AddLine(rect.LeftTop(), rect.LeftBottom(), borderColor);
    rect.left += kAntTouchBorderWidth;
  }

  // 顶部边框
  if ((borders & B_TOP_BORDER) != 0) {
    view->AddLine(rect.LeftTop(), rect.RightTop(), borderColor);
    rect.top += kAntTouchBorderWidth;
  }

  // 右侧边框
  if ((borders & B_RIGHT_BORDER) != 0) {
    view->AddLine(rect.RightTop(), rect.RightBottom(), borderColor);
    rect.right -= kAntTouchBorderWidth;
  }

  // 底部边框
  if ((borders & B_BOTTOM_BORDER) != 0) {
    view->AddLine(rect.LeftBottom(), rect.RightBottom(), borderColor);
    rect.bottom -= kAntTouchBorderWidth;
  }

  view->EndLineArray();

  // 焦点状态处理
  if (isEnabled && isFocused) {
    // 使用Ant Design风格的焦点边框
    view->SetHighColor(focusColor);
    view->StrokeRect(rect, B_SOLID_HIGH);
    rect.InsetBy(kAntTouchFocusOutlineWidth, kAntTouchFocusOutlineWidth);
  }

  view->PopState();
}

// 绘制分组框(根据Ant Design规范)
// 参数:
//   view - 绘制目标视图
//   rect - 矩形区域
//   updateRect - 需要更新的区域
//   base - 基础颜色
//   borders - 需要绘制的边框
void AntRedControlLook::DrawGroupFrame(BView* view, BRect& rect,
                                       const BRect& updateRect,
                                       const rgb_color& base, uint32 borders) {
  // 使用Ant Design风格的圆角边框
  DrawBorder(view, rect, updateRect, base, B_FANCY_BORDER, 0, borders);
}

//	#pragma mark - Labels

// 绘制文本标签(矩形区域版本)
// 参数:
//   view - 绘制目标视图
//   label - 标签文本
//   rect - 绘制区域
//   updateRect - 需要更新的区域
//   base - 基础颜色
//   flags - 控件状态标志
//   textColor - 文本颜色(可选)
void AntRedControlLook::DrawLabel(BView* view, const char* label, BRect rect,
                                  const BRect& updateRect,
                                  const rgb_color& base, uint32 flags,
                                  const rgb_color* textColor) {
  // 使用默认对齐方式和Ant Design标准间距
  DrawLabel(view, label, NULL, rect, updateRect, base, flags,
            BAlignment(B_ALIGN_LEFT, B_ALIGN_MIDDLE), textColor);
}

// 绘制文本标签(带对齐方式版本)
// 参数:
//   view - 绘制目标视图
//   label - 标签文本
//   rect - 绘制区域
//   updateRect - 需要更新的区域
//   base - 基础颜色
//   flags - 控件状态标志
//   alignment - 对齐方式
//   textColor - 文本颜色(可选)
void AntRedControlLook::DrawLabel(BView* view, const char* label, BRect rect,
                                  const BRect& updateRect,
                                  const rgb_color& base, uint32 flags,
                                  const BAlignment& alignment,
                                  const rgb_color* textColor) {
  // 使用Ant Design标准实现，增加触摸友好间距
  DrawLabel(view, label, NULL,
            rect.InsetByCopy(kAntTouchPadding / 4, kAntTouchPadding / 4),
            updateRect, base, flags, alignment, textColor);
}

// 绘制文本标签(根据Ant Design规范)
// 参数:
//   view - 绘制目标视图
//   label - 要绘制的文本
//   base - 基础颜色
//   flags - 控件状态标志
//   where - 绘制位置
//   textColor - 文本颜色(可选)
void AntRedControlLook::DrawLabel(BView* view, const char* label,
                                  const rgb_color& base, uint32 flags,
                                  const BPoint& where,
                                  const rgb_color* textColor) {
  view->PushState();

  // 确定控件类型和状态
  bool isButton = (flags & B_FLAT) != 0 || (flags & B_HOVER) != 0 ||
                  (flags & B_DEFAULT_BUTTON) != 0;
  bool isEnabled = (flags & B_DISABLED) == 0;
  bool isActivated = (flags & B_ACTIVATED) != 0;

  // 检查是否是桌面标签
  BWindow* window = view->Window();
  bool isDesktop = window != NULL && window->Feel() == kDesktopWindowFeel &&
                   window->Look() == kDesktopWindowLook && view->Parent() &&
                   view->Parent()->Parent() == NULL &&
                   (flags & B_IGNORE_OUTLINE) == 0;

  // 确定文本颜色
  rgb_color finalColor;
  if (textColor != NULL) {
    finalColor = *textColor;
  } else {
    // 使用Ant Design默认文本颜色
    finalColor = isEnabled ? kAntNeutral7 : kAntNeutral5;
  }

  // 处理桌面标签的特殊情况
  if (isDesktop) {
    rgb_color low = view->Parent()->ViewColor();
    if (low.IsDark()) {
      if (textColor == NULL) finalColor = kAntNeutral1;  // 白色
    } else {
      if (textColor == NULL) finalColor = kAntNeutral9;  // 深灰色
    }

    // 处理桌面标签的轮廓效果
    if (fCachedOutline) {
      BFont font;
      view->GetFont(&font);

      // 使用Ant Design风格的轮廓效果
      view->SetDrawingMode(B_OP_ALPHA);
      view->SetBlendingMode(B_CONSTANT_ALPHA, B_ALPHA_OVERLAY);

      // 根据背景色调整轮廓效果
      if (low.IsDark()) {
        // 深色背景使用浅色轮廓
        font.SetFalseBoldWidth(1.5f);
        view->SetFont(&font, B_FONT_FALSE_BOLD_WIDTH);
        view->SetHighColor(tint_color(finalColor, B_LIGHTEN_1_TINT));
        view->DrawString(label, where);
      } else {
        // 浅色背景使用深色轮廓
        font.SetFalseBoldWidth(1.2f);
        view->SetFont(&font, B_FONT_FALSE_BOLD_WIDTH);
        view->SetHighColor(tint_color(finalColor, B_DARKEN_1_TINT));
        view->DrawString(label, where);
      }

      font.SetFalseBoldWidth(0.0f);
      view->SetFont(&font, B_FONT_FALSE_BOLD_WIDTH);
    }
  }

  // 处理按钮激活状态的反色效果
  if (isButton && isEnabled && isActivated) {
    finalColor.red = 255 - finalColor.red;
    finalColor.green = 255 - finalColor.green;
    finalColor.blue = 255 - finalColor.blue;
  }

  // 禁用状态处理
  if (!isEnabled) {
    finalColor = tint_color(finalColor, B_LIGHTEN_2_TINT);
  }

  // 设置绘制参数并绘制文本
  view->SetLowColor(finalColor);
  view->SetHighColor(finalColor);
  view->SetDrawingMode(B_OP_OVER);
  view->DrawString(label, where);
  view->SetDrawingMode(B_OP_COPY);

  view->PopState();
}

// 绘制带图标的标签(根据Ant Design规范)
// 参数:
//   view - 绘制目标视图
//   label - 标签文本
//   icon - 图标位图
//   rect - 绘制区域
//   updateRect - 需要更新的区域
//   base - 基础颜色
//   flags - 控件状态标志
//   alignment - 对齐方式
//   textColor - 文本颜色(可选)
void AntRedControlLook::DrawLabel(BView* view, const char* label,
                                  const BBitmap* icon, BRect rect,
                                  const BRect& updateRect,
                                  const rgb_color& base, uint32 flags,
                                  const BAlignment& alignment,
                                  const rgb_color* textColor) {
  // 检查是否需要绘制
  if (!ShouldDraw(view, rect, updateRect)) return;

  // 无内容时直接返回
  if (label == NULL && icon == NULL) return;

  // 仅绘制图标的情况
  if (label == NULL && icon != NULL) {
    // 计算图标位置(增加触摸友好间距)
    BRect alignedRect = BLayoutUtils::AlignInFrame(
        rect.OffsetByCopy(-kAntTouchPadding / 4, -kAntTouchPadding / 4),
        icon->Bounds().Size(), alignment);

    view->SetDrawingMode(B_OP_OVER);
    view->DrawBitmap(icon, alignedRect.LeftTop());
    view->SetDrawingMode(B_OP_COPY);
    return;
  }

  view->PushState();

  // 计算可用宽度和高度
  float availableWidth = rect.Width() + 1;
  float width = 0;
  float textOffset = 0;
  float height = 0;

  // 同时有图标和文本的情况
  if (icon != NULL && label != NULL) {
    // 增加图标与文本间距(使用Ant Design标准间距)
    width = icon->Bounds().Width() + kAntTouchPadding / 2;
    height = icon->Bounds().Height() + 1;
    textOffset = width;
    availableWidth -= textOffset;
  }

  // 处理文本截断
  BString truncatedLabel(label);
  BFont font;
  view->GetFont(&font);

  // 使用Ant Design标准字体截断方式
  font.TruncateString(&truncatedLabel, B_TRUNCATE_END, availableWidth);
  width += ceilf(font.StringWidth(truncatedLabel.String()));

  // 计算文本高度
  font_height fontHeight;
  font.GetHeight(&fontHeight);
  float textHeight = ceilf(fontHeight.ascent) + ceilf(fontHeight.descent);
  height = std::max(height, textHeight);

  // 处理对齐
  BRect alignedRect(
      BLayoutUtils::AlignOnRect(rect, BSize(width - 1, height - 1), alignment));

  // 绘制图标(如果有)
  if (icon != NULL) {
    BPoint location(alignedRect.LeftTop());
    // 垂直居中图标
    if (icon->Bounds().Height() + 1 < height)
      location.y += ceilf((height - icon->Bounds().Height() - 1) / 2);

    view->SetDrawingMode(B_OP_OVER);
    view->DrawBitmap(icon, location);
    view->SetDrawingMode(B_OP_COPY);
  }

  // 计算文本位置
  BPoint location(alignedRect.left + textOffset,
                  alignedRect.top + ceilf(fontHeight.ascent));
  // 垂直居中文本
  if (textHeight < height) location.y += ceilf((height - textHeight) / 2);

  // 焦点状态处理(使用Ant Design风格)
  if ((flags & B_FOCUSED) != 0) {
    float x = location.x;
    float y = location.y + ceilf(fontHeight.descent);
    // 使用Ant Design主色作为焦点指示
    view->SetHighColor(kAntPrimaryColor);
    view->StrokeLine(BPoint(x, y),
                     BPoint(x + view->StringWidth(truncatedLabel.String()), y),
                     B_SOLID_HIGH);
  }

  // 设置文本颜色(默认使用Ant Design中性色)
  rgb_color finalColor = textColor ? *textColor : kAntNeutral7;
  if ((flags & B_DISABLED) != 0) {
    // 禁用状态使用更浅的颜色
    finalColor = tint_color(finalColor, B_LIGHTEN_2_TINT);
  }
  view->SetHighColor(finalColor);

  // 绘制文本
  view->SetDrawingMode(B_OP_OVER);
  view->DrawString(truncatedLabel.String(), location);
  view->SetDrawingMode(B_OP_COPY);

  view->PopState();
}

// 获取控件边框的内边距(根据Ant Design规范)
// 参数:
//   frameType - 边框类型
//   flags - 控件状态标志
//   _left/_top/_right/_bottom - 返回各方向的内边距值
void AntRedControlLook::GetFrameInsets(frame_type frameType, uint32 flags,
                                       float& _left, float& _top, float& _right,
                                       float& _bottom) {
  // 默认使用Ant Design触摸友好的内边距
  float inset = kAntTouchPadding / 2;  // 默认8px内边距

  switch (frameType) {
    case B_BUTTON_FRAME:
      // 按钮边框 - 默认按钮使用更大内边距
      inset = (flags & B_DEFAULT_BUTTON) != 0 ? kAntTouchPadding
                                              : kAntTouchPadding / 2;
      break;

    case B_GROUP_FRAME:
      // 分组框边框 - 使用中等内边距
      inset = kAntTouchPadding / 2;  // 8px
      break;

    case B_MENU_FIELD_FRAME:
      // 菜单字段边框 - 使用更紧凑的内边距
      inset = kAntTouchPadding / 4;  // 4px
      break;

    case B_SCROLL_VIEW_FRAME:
      // 滚动视图边框 - 使用最小内边距
      inset = kAntTouchBorderWidth;  // 1px
      break;

    case B_TEXT_CONTROL_FRAME:
      // 文本控件边框 - 使用中等内边距
      inset = kAntTouchPadding / 4;  // 4px
      break;
  }

  // 设置统一的内边距
  _left = inset;
  _top = inset;
  _right = inset;
  _bottom = inset;
}

// 获取控件背景的内边距(根据Ant Design规范)
// 参数:
//   backgroundType - 背景类型
//   flags - 控件状态标志
//   _left/_top/_right/_bottom - 返回各方向的内边距值
void AntRedControlLook::GetBackgroundInsets(background_type backgroundType,
                                            uint32 flags, float& _left,
                                            float& _top, float& _right,
                                            float& _bottom) {
  // 默认使用Ant Design触摸友好的内边距
  float inset = kAntTouchPadding;  // 16px默认内边距

  switch (backgroundType) {
    case B_BUTTON_BACKGROUND:
      // 按钮背景 - 使用更宽松的内边距
      inset = kAntTouchPadding;
      break;

    case B_MENU_BACKGROUND:
    case B_MENU_BAR_BACKGROUND:
    case B_MENU_FIELD_BACKGROUND:
    case B_MENU_ITEM_BACKGROUND:
      // 菜单相关控件 - 使用中等内边距
      inset = kAntTouchPadding / 2;  // 8px
      break;

    case B_BUTTON_WITH_POP_UP_BACKGROUND:
      // 带下拉菜单的按钮 - 右侧留出更多空间给下拉箭头
      _left = kAntTouchPadding;
      _top = kAntTouchPadding;
      _right = kAntTouchPadding + kButtonPopUpIndicatorWidth;
      _bottom = kAntTouchPadding;
      return;

    case B_HORIZONTAL_SCROLL_BAR_BACKGROUND:
      // 水平滚动条背景 - 上下边距不同
      _left = kAntTouchPadding / 2;
      _top = 0;
      _right = kAntTouchPadding / 4;
      _bottom = 0;
      return;

    case B_VERTICAL_SCROLL_BAR_BACKGROUND:
      // 垂直滚动条背景 - 左右边距不同
      _left = 0;
      _top = kAntTouchPadding / 2;
      _right = 0;
      _bottom = kAntTouchPadding / 4;
      return;

    default:
      // 其他类型保持默认内边距
      break;
  }

  // 设置统一的内边距
  _left = inset;
  _top = inset;
  _right = inset;
  _bottom = inset;
}

// 绘制带下拉菜单的按钮背景(无圆角版本)
// 参数:
//   view - 绘制目标视图
//   rect - 按钮矩形区域(会被修改)
//   updateRect - 需要更新的区域
//   base - 基础颜色
//   flags - 控件状态标志
//   borders - 需要绘制的边框
//   orientation - 方向(水平/垂直)
void AntRedControlLook::DrawButtonWithPopUpBackground(
    BView* view, BRect& rect, const BRect& updateRect, const rgb_color& base,
    uint32 flags, uint32 borders, orientation orientation) {
  // 使用Ant Design默认圆角半径和触摸友好尺寸
  _DrawButtonBackground(view, rect, updateRect, kAntTouchRadius,
                        kAntTouchRadius, kAntTouchRadius, kAntTouchRadius, base,
                        true, flags, borders, orientation);
}

// 绘制带下拉菜单的按钮背景(统一圆角版本)
// 参数:
//   view - 绘制目标视图
//   rect - 按钮矩形区域(会被修改)
//   updateRect - 需要更新的区域
//   radius - 统一圆角半径
//   base - 基础颜色
//   flags - 控件状态标志
//   borders - 需要绘制的边框
//   orientation - 方向(水平/垂直)
void AntRedControlLook::DrawButtonWithPopUpBackground(
    BView* view, BRect& rect, const BRect& updateRect, float radius,
    const rgb_color& base, uint32 flags, uint32 borders,
    orientation orientation) {
  // 确保圆角半径不小于最小触摸友好尺寸
  float adjustedRadius = std::max(radius, kAntTouchRadius);
  _DrawButtonBackground(view, rect, updateRect, adjustedRadius, adjustedRadius,
                        adjustedRadius, adjustedRadius, base, true, flags,
                        borders, orientation);
}

// 绘制带下拉菜单的按钮背景(自定义圆角版本)
// 参数:
//   view - 绘制目标视图
//   rect - 按钮矩形区域(会被修改)
//   updateRect - 需要更新的区域
//   leftTopRadius - 左上角圆角半径
//   rightTopRadius - 右上角圆角半径
//   leftBottomRadius - 左下角圆角半径
//   rightBottomRadius - 右下角圆角半径
//   base - 基础颜色
//   flags - 控件状态标志
//   borders - 需要绘制的边框
//   orientation - 方向(水平/垂直)
void AntRedControlLook::DrawButtonWithPopUpBackground(
    BView* view, BRect& rect, const BRect& updateRect, float leftTopRadius,
    float rightTopRadius, float leftBottomRadius, float rightBottomRadius,
    const rgb_color& base, uint32 flags, uint32 borders,
    orientation orientation) {
  // 调整各角圆角半径，确保不小于最小触摸友好尺寸
  leftTopRadius = std::max(leftTopRadius, kAntTouchRadius);
  rightTopRadius = std::max(rightTopRadius, kAntTouchRadius);
  leftBottomRadius = std::max(leftBottomRadius, kAntTouchRadius);
  rightBottomRadius = std::max(rightBottomRadius, kAntTouchRadius);

  _DrawButtonBackground(view, rect, updateRect, leftTopRadius, rightTopRadius,
                        leftBottomRadius, rightBottomRadius, base, true, flags,
                        borders, orientation);
}

//	#pragma mark - protected methods

// 绘制Ant Design风格的按钮边框
// 参数:
//   view - 绘制目标视图
//   rect - 矩形区域(会被修改)
//   updateRect - 需要更新的区域
//   base - 基础颜色
//   background - 背景颜色
//   contrast - 对比度
//   brightness - 亮度
//   flags - 控件状态标志
//   borders - 需要绘制的边框
void AntRedControlLook::_DrawButtonFrame(BView* view, BRect& rect,
                                         const BRect& updateRect, float, float,
                                         float, float, const rgb_color& base,
                                         const rgb_color& background,
                                         float contrast, float brightness,
                                         uint32 flags, uint32 borders) {
  // 检查是否需要绘制，避免不必要的绘制操作
  if (!ShouldDraw(view, rect, updateRect)) return;

  view->PushState();
  view->ClipToRect(rect);

  // 控件状态
  bool isEnabled = (flags & B_DISABLED) == 0;
  bool isDefault = (flags & B_DEFAULT_BUTTON) != 0;
  bool isActivated = (flags & B_ACTIVATED) != 0;
  bool isHovered = (flags & B_HOVER) != 0;

  // 使用Ant Design颜色方案
  rgb_color lighten1 = tint_color(base, B_LIGHTEN_1_TINT);
  rgb_color lighten2 = tint_color(base, B_LIGHTEN_2_TINT);
  rgb_color lightenMax = tint_color(base, B_LIGHTEN_MAX_TINT);
  rgb_color darken1 = tint_color(base, B_DARKEN_1_TINT);
  rgb_color darken2 = tint_color(base, B_DARKEN_2_TINT);
  rgb_color darken3 = tint_color(base, B_DARKEN_3_TINT);
  rgb_color darken4 = tint_color(base, B_DARKEN_4_TINT);

  // 默认按钮使用主色，普通按钮使用中性色
  rgb_color buttonBgColor = isDefault ? kAntPrimaryColor : kAntNeutral2;
  rgb_color borderColor =
      isDefault ? tint_color(kAntPrimaryColor, B_DARKEN_1_TINT) : kAntNeutral5;

  // 禁用状态颜色处理
  if (!isEnabled) {
    buttonBgColor = tint_color(kAntNeutral3, B_LIGHTEN_2_TINT);
    borderColor = tint_color(kAntNeutral5, B_LIGHTEN_2_TINT);
  }

  // 填充按钮背景
  view->SetHighColor(buttonBgColor);
  view->FillRect(rect);

  // 绘制边框
  view->BeginLineArray(4);

  // 左侧边框
  if ((borders & B_LEFT_BORDER) != 0) {
    view->AddLine(BPoint(rect.left, rect.top), BPoint(rect.left, rect.bottom),
                  borderColor);
    rect.left += kAntTouchBorderWidth;
  }

  // 顶部边框
  if ((borders & B_TOP_BORDER) != 0) {
    view->AddLine(BPoint(rect.left, rect.top), BPoint(rect.right, rect.top),
                  borderColor);
    rect.top += kAntTouchBorderWidth;
  }

  // 右侧边框
  if ((borders & B_RIGHT_BORDER) != 0) {
    view->AddLine(BPoint(rect.right, rect.top), BPoint(rect.right, rect.bottom),
                  borderColor);
    rect.right -= kAntTouchBorderWidth;
  }

  // 底部边框
  if ((borders & B_BOTTOM_BORDER) != 0) {
    view->AddLine(BPoint(rect.left, rect.bottom),
                  BPoint(rect.right, rect.bottom), borderColor);
    rect.bottom -= kAntTouchBorderWidth;
  }

  view->EndLineArray();

  // 处理按钮交互状态
  if (isEnabled) {
    if (isActivated) {
      // 激活状态 - 加深颜色
      rgb_color pressedColor = tint_color(buttonBgColor, B_DARKEN_1_TINT);
      view->SetHighColor(pressedColor);
      view->FillRect(rect);
    } else if (isHovered) {
      // 悬停状态 - 半透明高亮
      rgb_color hoverColor = tint_color(buttonBgColor, B_LIGHTEN_1_TINT);
      view->SetHighColor(hoverColor);
      view->SetDrawingMode(B_OP_ALPHA);
      view->FillRect(rect);
      view->SetDrawingMode(B_OP_COPY);
    }
  }

  view->PopState();
}

// 绘制Ant Design风格的按钮背景
// 参数:
//   view - 绘制目标视图
//   rect - 矩形区域(会被修改)
//   updateRect - 需要更新的区域
//   base - 基础颜色
//   popupIndicator - 是否显示下拉指示器
//   flags - 控件状态标志
//   borders - 需要绘制的边框
//   orientation - 方向(水平/垂直)
void AntRedControlLook::_DrawButtonBackground(
    BView* view, BRect& rect, const BRect& updateRect, float, float, float,
    float, const rgb_color& base, bool popupIndicator, uint32 flags,
    uint32 borders, orientation orientation) {
  // 检查是否需要绘制，避免不必要的绘制操作
  if (!ShouldDraw(view, rect, updateRect)) return;

  // 控件状态
  bool isEnabled = (flags & B_DISABLED) == 0;
  bool isActivated = (flags & B_ACTIVATED) != 0;
  bool isDefault = (flags & B_DEFAULT_BUTTON) != 0;

  // 使用Ant Design颜色方案
  rgb_color backgroundColor =
      isEnabled ? (isDefault ? kAntPrimaryColor : kAntNeutral2)
                : tint_color(kAntNeutral2, B_LIGHTEN_2_TINT);

  // 填充按钮背景 - 使用Ant Design中性色或主色
  view->SetHighColor(backgroundColor);
  view->FillRect(rect);

  // 处理按钮激活状态
  if (isEnabled && isActivated) {
    // 使用Ant Design风格的激活效果
    rgb_color pressedColor = tint_color(kAntPrimaryColor, B_DARKEN_1_TINT);
    view->SetHighColor(pressedColor);
    view->FillRect(rect);

    // 添加轻微阴影效果
    view->BeginLineArray(4);
    view->AddLine(rect.LeftBottom(), rect.RightBottom(),
                  tint_color(pressedColor, B_DARKEN_2_TINT));
    view->AddLine(rect.RightTop(), rect.RightBottom(),
                  tint_color(pressedColor, B_DARKEN_2_TINT));
    view->EndLineArray();
  }

  // 处理按钮悬停状态
  if ((flags & B_HOVER) != 0 && isEnabled) {
    // 使用Ant Design风格的悬停效果
    rgb_color hoverColor = tint_color(kAntPrimaryColor, B_LIGHTEN_1_TINT);
    view->SetHighColor(hoverColor);
    view->SetDrawingMode(B_OP_ALPHA);
    view->FillRect(rect);
    view->SetDrawingMode(B_OP_COPY);
  }
}

// 绘制Ant Design风格的下拉菜单指示器
// 参数:
//   view - 绘制目标视图
//   rect - 矩形区域
//   base - 基础颜色
//   flags - 控件状态标志
void AntRedControlLook::_DrawPopUpMarker(BView* view, const BRect& rect,
                                         const rgb_color& base, uint32 flags) {
  // 检查控件是否启用
  bool isEnabled = (flags & B_DISABLED) == 0;

  // 使用Ant Design风格的触摸友好尺寸
  const float kAntMarkerSize = 12.0f;    // 指示器尺寸
  const float kAntMarkerOffset = 12.0f;  // 指示器偏移量

  // 计算指示器位置 - 居中于rect右侧
  BPoint position(rect.right - kAntMarkerOffset, (rect.top + rect.bottom) / 2);

  // 定义三角形顶点坐标
  BPoint triangle[3];
  triangle[0] = position + BPoint(-kAntMarkerSize / 2, -kAntMarkerSize / 3);
  triangle[1] = position + BPoint(kAntMarkerSize / 2, -kAntMarkerSize / 3);
  triangle[2] = position + BPoint(0.0, kAntMarkerSize / 3);

  // 启用亚像素精度绘制
  uint32 viewFlags = view->Flags();
  view->SetFlags(viewFlags | B_SUBPIXEL_PRECISE);

  // 使用Ant Design颜色方案
  rgb_color markerColor = isEnabled ? kAntNeutral7 : kAntNeutral5;

  // 绘制三角形指示器
  view->SetHighColor(markerColor);
  view->FillTriangle(triangle[0], triangle[1], triangle[2]);

  // 恢复原始绘制状态
  view->SetFlags(viewFlags);
}

// 绘制菜单字段外部背景(完整Ant Design实现)
// 参数:
//   view - 绘制目标视图
//   rect - 矩形区域(会被修改)
//   updateRect - 需要更新的区域
//   base - 基础颜色
//   popupIndicator - 是否显示下拉指示器
//   flags - 控件状态标志
void AntRedControlLook::_DrawMenuFieldBackgroundOutside(
    BView* view, BRect& rect, const BRect& updateRect, float, float, float,
    float, const rgb_color& base, bool popupIndicator, uint32 flags) {
  // 检查是否需要绘制
  if (!ShouldDraw(view, rect, updateRect)) return;

  view->PushState();
  
  // 确保下拉框高度足够大，适合触摸操作 - 使用专门的下拉框高度常量
  if (rect.Height() < kAntTouchDropdownHeight) {
    float centerY = (rect.top + rect.bottom) / 2;
    rect.top = centerY - kAntTouchDropdownHeight / 2;
    rect.bottom = centerY + kAntTouchDropdownHeight / 2;
  }

  // 使用Ant Design颜色方案
  bool isEnabled = (flags & B_DISABLED) == 0;
  bool isFocused = (flags & B_FOCUSED) != 0;
  bool isHovered = (flags & B_HOVER) != 0;

  // 设置不同状态下的背景色
  rgb_color backgroundColor;
  if (!isEnabled) {
    // 禁用状态 - 使用中性色且降低透明度
    backgroundColor = tint_color(kAntNeutral3, 0.7f);
  } else if (isFocused) {
    // 焦点状态 - 使用浅色背景
    backgroundColor = tint_color(kAntNeutral2, B_LIGHTEN_1_TINT);
  } else if (isHovered) {
    // 悬停状态 - 使用更浅的背景
    backgroundColor = tint_color(kAntNeutral2, B_LIGHTEN_2_TINT);
  } else {
    // 默认状态 - 使用中性背景色
    backgroundColor = kAntNeutral2;
  }

  // 增加触摸友好内边距
  rect.InsetBy(kAntTouchPadding / 4, kAntTouchPadding / 4);

  // 绘制圆角背景
  view->SetHighColor(backgroundColor);
  view->FillRoundRect(rect, kAntTouchRadius, kAntTouchRadius);

  // 绘制边框
  rgb_color borderColor =
      isEnabled ? kAntNeutral5 : tint_color(kAntNeutral5, 0.7f);
  view->SetHighColor(borderColor);
  view->SetPenSize(kAntTouchBorderWidth);
  view->StrokeRoundRect(rect, kAntTouchRadius, kAntTouchRadius);

  // 焦点状态处理 - 使用桃花缘主色作为焦点边框
  if (isEnabled && isFocused) {
    BRect focusRect = rect;
    focusRect.InsetBy(-kAntTouchFocusOutlineWidth, -kAntTouchFocusOutlineWidth);
    view->SetHighColor(kAntPrimaryColor);
    view->StrokeRoundRect(focusRect,
                          kAntTouchRadius + kAntTouchFocusOutlineWidth,
                          kAntTouchRadius + kAntTouchFocusOutlineWidth);
  }

  // 处理下拉指示器
  if (popupIndicator) {
    // 计算指示器区域(增加触摸友好尺寸)
    BRect indicatorRect = rect;
    indicatorRect.left = indicatorRect.right - kAntTouchPadding;

    // 绘制分隔线
    view->SetHighColor(kAntNeutral4);
    view->StrokeLine(BPoint(indicatorRect.left, indicatorRect.top + 2),
                     BPoint(indicatorRect.left, indicatorRect.bottom - 2));

    // 绘制下拉箭头 - 使用Ant Design风格
    _DrawPopUpMarker(view, indicatorRect,
                     isEnabled ? kAntPrimaryColor : kAntNeutral5, flags);
  }

  view->PopState();
}

// 绘制Ant Design风格的下拉菜单内部背景
// 参数:
//   view - 绘制目标视图
//   rect - 矩形区域(会被修改)
//   updateRect - 需要更新的区域
//   base - 基础颜色
//   flags - 控件状态标志
//   borders - 需要绘制的边框
void AntRedControlLook::_DrawMenuFieldBackgroundInside(
    BView* view, BRect& rect, const BRect& updateRect, float, float, float,
    float, const rgb_color& base, uint32 flags, uint32 borders) {
  // 检查是否需要绘制，避免不必要的绘制操作
  if (!ShouldDraw(view, rect, updateRect)) return;

  view->PushState();
  view->ClipToRect(rect);

  // 控件状态
  bool isEnabled = (flags & B_DISABLED) == 0;

  // 使用Ant Design颜色方案
  rgb_color darken4 =
      isEnabled ? kAntNeutral7 : tint_color(kAntNeutral7, B_LIGHTEN_2_TINT);
  rgb_color darken1 =
      isEnabled ? kAntNeutral5 : tint_color(kAntNeutral5, B_LIGHTEN_2_TINT);
  rgb_color lighten1 =
      isEnabled ? kAntNeutral3 : tint_color(kAntNeutral3, B_LIGHTEN_2_TINT);
  rgb_color lighten2 =
      isEnabled ? kAntNeutral2 : tint_color(kAntNeutral2, B_LIGHTEN_2_TINT);

  // 填充背景色 - 使用Ant Design中性色
  view->SetHighColor(base);
  view->FillRect(rect);

  // 绘制边框和阴影效果
  view->BeginLineArray(6);

  // 底部边框 - 使用较深颜色
  if ((borders & B_BOTTOM_BORDER) != 0) {
    view->AddLine(BPoint(rect.left, rect.bottom),
                  BPoint(rect.left - 1, rect.bottom), darken4);
    view->AddLine(BPoint(rect.left, rect.bottom),
                  BPoint(rect.right, rect.bottom), darken4);
  }

  // 右侧边框 - 使用较深颜色
  if ((borders & B_RIGHT_BORDER) != 0) {
    view->AddLine(BPoint(rect.right, rect.bottom - 1),
                  BPoint(rect.right, rect.top), darken4);
  }

  // 顶部高光 - 使用较浅颜色
  if ((borders & B_TOP_BORDER) != 0) {
    view->AddLine(BPoint(rect.left, rect.top), BPoint(rect.right - 2, rect.top),
                  lighten2);
  }

  // 调整矩形区域，为内部内容留出空间
  rect.top += kAntTouchBorderWidth;
  rect.bottom -= kAntTouchBorderWidth;
  rect.right -= kAntTouchBorderWidth;

  // 内部边框 - 使用中等深度颜色
  if ((borders & B_BOTTOM_BORDER) != 0) {
    view->AddLine(BPoint(rect.left, rect.bottom),
                  BPoint(rect.right, rect.bottom), darken1);
  }
  if ((borders & B_RIGHT_BORDER) != 0) {
    view->AddLine(BPoint(rect.right, rect.bottom - 1),
                  BPoint(rect.right, rect.top), darken1);
  }

  view->EndLineArray();

  // 进一步调整矩形区域
  rect.bottom -= kAntTouchBorderWidth;
  rect.right -= kAntTouchBorderWidth;

  // 填充最终内部区域
  view->SetHighColor(base);
  view->FillRect(rect);

  view->PopState();
}

// 绘制Ant Design风格的滚动条背景第一部分
// 参数:
//   view - 绘制目标视图
//   rect - 矩形区域(会被修改)
//   updateRect - 需要更新的区域
//   base - 基础颜色
//   flags - 控件状态标志
//   orientation - 方向(水平/垂直)
void AntRedControlLook::_DrawScrollBarBackgroundFirst(BView* view, BRect& rect,
                                                      const BRect& updateRect,
                                                      const rgb_color& base,
                                                      uint32 flags,
                                                      orientation orientation) {
  // 检查是否需要绘制，避免不必要的绘制操作
  if (!ShouldDraw(view, rect, updateRect)) return;

  view->PushState();
  view->ClipToRect(rect);

  bool isEnabled = (flags & B_DISABLED) == 0;
  BRect orig(rect);

  // 使用Ant Design颜色方案
  rgb_color border =
      isEnabled ? kAntNeutral5 : tint_color(kAntNeutral5, B_LIGHTEN_2_TINT);
  rgb_color shine =
      isEnabled ? kAntNeutral2 : tint_color(kAntNeutral2, B_LIGHTEN_2_TINT);
  rgb_color shadow =
      isEnabled ? kAntNeutral4 : tint_color(kAntNeutral4, B_LIGHTEN_2_TINT);
  rgb_color bg =
      isEnabled ? kAntNeutral3 : tint_color(kAntNeutral3, B_LIGHTEN_2_TINT);

  // 填充背景，我们将在上面绘制箭头和滑块
  view->SetDrawingMode(B_OP_COPY);

  // 绘制3D效果边框
  view->BeginLineArray(5);
  if (orientation == B_VERTICAL) {
    // 垂直滚动条 - 左侧阴影
    view->AddLine(rect.LeftTop(), rect.LeftBottom(),
                  isEnabled ? shadow : shine);
    rect.left += kAntTouchBorderWidth;  // 增加边框宽度以适应触摸

    view->AddLine(rect.LeftTop(), rect.LeftBottom(), shadow);
    rect.left += kAntTouchBorderWidth;

    // 顶部阴影
    view->AddLine(rect.LeftTop(), rect.RightTop(), isEnabled ? shadow : shine);
    rect.top += kAntTouchBorderWidth;

    view->AddLine(rect.LeftTop(), rect.RightTop(), shadow);
    rect.top += kAntTouchBorderWidth;

    // 右侧高光 - 使用基础颜色
    view->AddLine(rect.RightTop(), rect.RightBottom(), shine);
    rect.right -= kAntTouchBorderWidth;
  } else {
    // 水平滚动条 - 左侧阴影
    view->AddLine(rect.LeftTop(), rect.LeftBottom(), shadow);
    rect.left += kAntTouchBorderWidth;

    view->AddLine(rect.LeftTop(), rect.LeftBottom(), shadow);
    rect.left += kAntTouchBorderWidth;

    // 顶部阴影
    view->AddLine(rect.LeftTop(), rect.RightTop(), shadow);
    rect.top += kAntTouchBorderWidth;

    view->AddLine(rect.LeftTop(), rect.RightTop(), shadow);
    rect.top += kAntTouchBorderWidth;

    // 底部高光 - 使用基础颜色
    view->AddLine(rect.LeftBottom(), rect.RightBottom(), shine);
    rect.bottom -= kAntTouchBorderWidth;
  }
  view->EndLineArray();

  // 填充背景色
  view->SetHighColor(bg);
  view->FillRect(rect);

  rect = orig;

  // 在背景上绘制边框
  view->BeginLineArray(2);
  if (orientation == B_VERTICAL) {
    // 垂直滚动条 - 顶部边框
    view->AddLine(rect.LeftTop(), rect.RightTop(), border);
    // 底部边框
    view->AddLine(rect.LeftBottom(), rect.RightBottom(), border);
  } else {
    // 水平滚动条 - 左侧边框
    view->AddLine(rect.LeftTop(), rect.LeftBottom(), border);
    // 右侧边框
    view->AddLine(rect.RightTop(), rect.RightBottom(), border);
  }
  view->EndLineArray();

  view->PopState();
}

// 绘制Ant Design风格的滚动条背景第二部分
// 参数:
//   view - 绘制目标视图
//   rect - 矩形区域(会被修改)
//   updateRect - 需要更新的区域
//   base - 基础颜色
//   flags - 控件状态标志
//   orientation - 方向(水平/垂直)
void AntRedControlLook::_DrawScrollBarBackgroundSecond(
    BView* view, BRect& rect, const BRect& updateRect, const rgb_color& base,
    uint32 flags, orientation orientation) {
  // 检查是否需要绘制，避免不必要的绘制操作
  if (!ShouldDraw(view, rect, updateRect)) return;

  view->PushState();
  view->ClipToRect(rect);

  bool isEnabled = (flags & B_DISABLED) == 0;
  BRect orig(rect);

  // 使用Ant Design颜色方案
  rgb_color border =
      isEnabled ? kAntNeutral5 : tint_color(kAntNeutral5, B_LIGHTEN_2_TINT);
  rgb_color darkBorder =
      isEnabled ? kAntNeutral7 : tint_color(kAntNeutral7, B_LIGHTEN_2_TINT);
  rgb_color shine =
      isEnabled ? kAntNeutral2 : tint_color(kAntNeutral2, B_LIGHTEN_2_TINT);
  rgb_color shadow =
      isEnabled ? kAntNeutral4 : tint_color(kAntNeutral4, B_LIGHTEN_2_TINT);
  rgb_color bg =
      isEnabled ? kAntNeutral3 : tint_color(kAntNeutral3, B_LIGHTEN_2_TINT);

  // 填充背景，我们将在上面绘制箭头和滑块
  view->SetDrawingMode(B_OP_COPY);

  // 绘制3D效果边框
  view->BeginLineArray(3);
  if (orientation == B_VERTICAL) {
    // 垂直滚动条 - 左侧阴影
    view->AddLine(rect.LeftTop(), rect.LeftBottom(),
                  isEnabled ? shadow : shine);
    rect.left += kAntTouchBorderWidth;  // 增加边框宽度以适应触摸

    view->AddLine(rect.LeftTop(), rect.LeftBottom(), shadow);
    rect.left += kAntTouchBorderWidth;

    // 右侧高光 - 使用基础颜色
    view->AddLine(rect.RightTop(), rect.RightBottom(), shine);
    rect.right -= kAntTouchBorderWidth;
  } else {
    // 水平滚动条 - 顶部阴影
    view->AddLine(rect.LeftTop(), rect.RightTop(), isEnabled ? shadow : shine);
    rect.top += kAntTouchBorderWidth;

    view->AddLine(rect.LeftTop(), rect.RightTop(), shadow);
    rect.top += kAntTouchBorderWidth;

    // 底部高光 - 使用基础颜色
    view->AddLine(rect.LeftBottom(), rect.RightBottom(), shine);
    rect.bottom -= kAntTouchBorderWidth;
  }
  view->EndLineArray();

  // 填充背景色
  view->SetHighColor(bg);
  view->FillRect(rect);

  rect = orig;

  // 在背景上绘制边框
  view->BeginLineArray(2);
  if (orientation == B_VERTICAL) {
    // 垂直滚动条 - 顶部边框
    view->AddLine(rect.LeftTop(), rect.RightTop(), darkBorder);
    // 底部边框
    view->AddLine(rect.LeftBottom(), rect.RightBottom(), border);
  } else {
    // 水平滚动条 - 左侧边框
    view->AddLine(rect.LeftTop(), rect.LeftBottom(), darkBorder);
    // 右侧边框
    view->AddLine(rect.RightTop(), rect.RightBottom(), border);
  }
  view->EndLineArray();

  view->PopState();
}

// 绘制Ant Design风格的滚动条滑块点
// 参数:
//   view - 绘制目标视图
//   hcenter/vmiddle - 中心点坐标
//   dark/light - 明暗颜色
//   orientation - 方向(水平/垂直)
void AntRedControlLook::_DrawScrollBarKnobDot(BView* view, float hcenter,
                                              float vmiddle, rgb_color dark,
                                              rgb_color light,
                                              orientation orientation) {
  // 使用Ant Design风格的触摸友好尺寸
  const float kTouchDotSize = 8.0f;    // 滑块点尺寸
  const float kTouchDotOffset = 3.0f;  // 滑块点偏移量

  view->BeginLineArray(4);
  // 右侧线 - 使用深色
  view->AddLine(BPoint(hcenter + kTouchDotOffset, vmiddle - kTouchDotOffset),
                BPoint(hcenter + kTouchDotOffset, vmiddle + kTouchDotOffset),
                dark);
  // 底部线 - 使用深色
  view->AddLine(BPoint(hcenter + kTouchDotOffset, vmiddle + kTouchDotOffset),
                BPoint(hcenter - kTouchDotOffset, vmiddle + kTouchDotOffset),
                dark);
  // 左侧线 - 使用浅色
  view->AddLine(
      BPoint(hcenter - kTouchDotOffset, vmiddle + kTouchDotOffset - 1),
      BPoint(hcenter - kTouchDotOffset, vmiddle - kTouchDotOffset + 1), light);
  // 顶部线 - 使用浅色
  view->AddLine(BPoint(hcenter - kTouchDotOffset, vmiddle - kTouchDotOffset),
                BPoint(hcenter - kTouchDotOffset, vmiddle + kTouchDotOffset),
                light);
  view->EndLineArray();
}

// 绘制Ant Design风格的滚动条滑块线条
// 参数:
//   view - 绘制目标视图
//   hcenter/vmiddle - 中心点坐标
//   dark/light - 明暗颜色
//   orientation - 方向(水平/垂直)
void AntRedControlLook::_DrawScrollBarKnobLine(BView* view, float hcenter,
                                               float vmiddle, rgb_color dark,
                                               rgb_color light,
                                               orientation orientation) {
  // 使用Ant Design风格的触摸友好尺寸
  const float kTouchKnobSize = 6.0f;    // 滑块线条尺寸
  const float kTouchKnobOffset = 4.0f;  // 滑块线条偏移量

  if (orientation == B_HORIZONTAL) {
    // 水平滚动条 - 绘制水平线条
    view->BeginLineArray(4);
    // 上边线 - 使用深色
    view->AddLine(BPoint(hcenter, vmiddle + kTouchKnobOffset),
                  BPoint(hcenter + 1, vmiddle + kTouchKnobOffset), dark);
    // 右边线 - 使用深色
    view->AddLine(BPoint(hcenter + 1, vmiddle + kTouchKnobOffset),
                  BPoint(hcenter + 1, vmiddle - kTouchKnobOffset), dark);
    // 下边线 - 使用浅色
    view->AddLine(BPoint(hcenter, vmiddle - kTouchKnobOffset),
                  BPoint(hcenter - 1, vmiddle - kTouchKnobOffset), light);
    // 左边线 - 使用浅色
    view->AddLine(BPoint(hcenter - 1, vmiddle - kTouchKnobOffset),
                  BPoint(hcenter - 1, vmiddle + kTouchKnobOffset), light);
    view->EndLineArray();
  } else {
    // 垂直滚动条 - 绘制垂直线条
    view->BeginLineArray(4);
    // 右边线 - 使用深色
    view->AddLine(BPoint(hcenter + kTouchKnobOffset, vmiddle),
                  BPoint(hcenter + kTouchKnobOffset, vmiddle + 1), dark);
    // 下边线 - 使用深色
    view->AddLine(BPoint(hcenter + kTouchKnobOffset, vmiddle + 1),
                  BPoint(hcenter - kTouchKnobOffset, vmiddle + 1), dark);
    // 左边线 - 使用浅色
    view->AddLine(BPoint(hcenter - kTouchKnobOffset, vmiddle),
                  BPoint(hcenter - kTouchKnobOffset, vmiddle - 1), light);
    // 上边线 - 使用浅色
    view->AddLine(BPoint(hcenter - kTouchKnobOffset, vmiddle - 1),
                  BPoint(hcenter + kTouchKnobOffset, vmiddle - 1), light);
    view->EndLineArray();
  }
}

// 绘制Ant Design风格的边框
// 参数:
//   view - 绘制目标视图
//   rect - 矩形区域(会被修改)
//   left/top/right/bottom - 各边颜色
//   borders - 需要绘制的边框(B_LEFT_BORDER等)
void AntRedControlLook::_DrawFrame(BView* view, BRect& rect,
                                   const rgb_color& left, const rgb_color& top,
                                   const rgb_color& right,
                                   const rgb_color& bottom, uint32 borders) {
  // 使用Ant Design风格的边框宽度
  const float borderWidth = kAntTouchBorderWidth;

  view->BeginLineArray(4);

  // 按照Ant Design规范，边框绘制顺序为: 底部->右侧->顶部->左侧
  // 这样可以确保角落重叠部分正确显示

  if ((borders & B_BOTTOM_BORDER) != 0) {
    // 底部边框 - 使用更宽的线条以适应触摸设计
    view->AddLine(BPoint(rect.left, rect.bottom),
                  BPoint(rect.right, rect.bottom), bottom);
    rect.bottom -= borderWidth;
  }
  if ((borders & B_RIGHT_BORDER) != 0) {
    // 右侧边框
    view->AddLine(BPoint(rect.right, rect.top), BPoint(rect.right, rect.bottom),
                  right);
    rect.right -= borderWidth;
  }
  if ((borders & B_TOP_BORDER) != 0) {
    // 顶部边框
    view->AddLine(BPoint(rect.left, rect.top), BPoint(rect.right, rect.top),
                  top);
    rect.top += borderWidth;
  }
  if ((borders & B_LEFT_BORDER) != 0) {
    // 左侧边框
    view->AddLine(BPoint(rect.left, rect.bottom), BPoint(rect.left, rect.top),
                  left);
    rect.left += borderWidth;
  }

  view->EndLineArray();
}

}  // namespace BPrivate

extern "C" BControlLook*(instantiate_control_look)(image_id id) {
  return new (std::nothrow) BPrivate::AntRedControlLook(id);
}
